Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.concurrent.CompletableFuture;

import com.vaadin.flow.component.ComponentEffect;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.NativeButton;
import com.vaadin.flow.component.html.Span;
Expand Down Expand Up @@ -39,13 +38,13 @@ public SignalsView() {
incrementButton = new NativeButton("Increment",
ev -> numberSignal.incrementBy(1.0));
counter = new Span("Counter: -");
ComponentEffect.bind(counter, computedSignal, Span::setText);
counter.bindText(computedSignal);

asyncNumberSignal = new SharedNumberSignal();
Signal<String> asyncComputedSignal = asyncNumberSignal
.mapIntValue(counter -> "Counter: " + counter);
asyncCounter = new Span("Counter: -");
ComponentEffect.bind(asyncCounter, asyncComputedSignal, Span::setText);
asyncCounter.bindText(asyncComputedSignal);

asyncWithDelayNumberSignal = new SharedNumberSignal();
asyncWithDelayCounter = new Span("Counter: -");
Expand All @@ -58,7 +57,7 @@ public SignalsView() {
java.util.concurrent.TimeUnit.MILLISECONDS));
});

ComponentEffect.effect(asyncWithDelayCounter, () -> {
Signal.effect(asyncWithDelayCounter, () -> {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import com.vaadin.flow.component.ComponentEffect;
import com.vaadin.flow.component.UI;

@ViewPackages(packages = "com.example.base.signals")
@Timeout(10)
public class SignalsTest extends UIUnitTest {
Expand Down Expand Up @@ -48,22 +45,6 @@ void detachedComponent_triggerSignal_effectEvaluatedOnAttach() {
Assertions.assertEquals("Counter: 1", view.counter.getText());
}

@Test
void detachedComponent_triggerEffect_effectEvaluatedAsynchronously() {
var view = navigate(SignalsView.class);
var counterTester = test(view.asyncCounter);
Assertions.assertEquals("Counter: 0", counterTester.getText());
UI ui = UI.getCurrent();
UI.setCurrent(null);

ComponentEffect.effect(ui,
() -> view.asyncCounter.setText("Counter: async"));
runPendingSignalsTasks();

UI.setCurrent(ui);
Assertions.assertEquals("Counter: async", view.asyncCounter.getText());
}

@Test
void attachedComponent_triggerSignalFromNonUIThread_effectEvaluatedAsynchronously() {
var view = navigate(SignalsView.class);
Expand Down
Loading