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 #595

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

runningProperty on DelegateCommand does not change #595

pbauerochse opened this issue Aug 1, 2019 · 1 comment

Comments

@pbauerochse
Copy link

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

@manuel-mauky
Copy link
Collaborator

Thanks for the bugreport and the test-case. This is a bug. In the past we were using DelegateCommand in background-mode most of the time and didn't use the runningProperty when in synchronous mode so we missed this. However, of cause this should work an I've fixed it with #596 (many thanks for the unit test. It made fixing it much faster).

manuel-mauky added a commit that referenced this issue Aug 2, 2019
…c_mode

#595 Fix runningProperty for DelegateCommand in sync mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants