andywer / andywer/threads.js

subscribe won't propagate falsey values

未关闭
#471 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
3.5k
派生
173
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。