Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runningProperty on DelegateCommand does not change #236

Closed
pbauerochse opened this issue Aug 1, 2019 · 1 comment
Closed

runningProperty on DelegateCommand does not change #236

pbauerochse opened this issue Aug 1, 2019 · 1 comment

Comments

@pbauerochse
Copy link

pbauerochse commented Aug 1, 2019

Hi there,

I have a non-background DelegateCommand and tried to attach a listener to the runningProperty but it does not get called, when i start the command via the execute() method. Is this intended behaviour?

I'm using MvvmFx Version 1.8.0. Here's a unit-test to verify the behaviour:

@Test
void test() {
    CountDownLatch commandExecutedLatch = new CountDownLatch(1);
    CountDownLatch listenerCalledLatch = new CountDownLatch(1);

    Command command = new DelegateCommand(() -> new Action() {
        @Override
        protected void action() throws Exception {
            commandExecutedLatch.countDown();
        }
    });

    command.runningProperty().addListener((observable, oldValue, newValue) -> {
        listenerCalledLatch.countDown();
    });

    // when
    command.execute();

    // then
    Assertions.assertDoesNotThrow(() -> {
        commandExecutedLatch.await(2, TimeUnit.SECONDS);
        listenerCalledLatch.await(2, TimeUnit.SECONDS);
    });

   Assertions.assertEquals(0, commandExecutedLatch.getCount(), "Action was not executed");
   Assertions.assertEquals(0, listenerCalledLatch.getCount(), "Listener was not invoked");
}

Cheers

Patrick

@pbauerochse
Copy link
Author

oh dang. Wrong mvvmfx project. Sorry for bothering you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant