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

subscribe won't propagate falsey values #471

Open
zapphyre opened this issue May 27, 2023 · 0 comments
Open

subscribe won't propagate falsey values #471

zapphyre opened this issue May 27, 2023 · 0 comments

Comments

@zapphyre
Copy link

zapphyre commented May 27, 2023

I have a setup that should propagate a value (GPIO pin state in this case) to it's subscribers:

(function ok_toggle(pin_state) {
    console.log(`ok_btn pin_state: ${pin_state}`)

    ok_button_subject.next(!!Number(pin_state));
    
    GPIO.pin_toggler(26)(1)(ok_toggle);
})(1);

what happens is that falsey values are not propagated to the subscriber.

again, point of interest i the line ok_button_subject.next(!!Number(pin_state)); so when .next(false) is being called, subscriber doesn't get called. ok_button_subject.next(Number(pin_state)); won't propagate either when pin_state=0

if modified to: ok_button_subject.next(pin_state+"");subscriber will get '0' and '1' values.

I would be surprised if this is intended behaviour, but want to check here.

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

1 participant