Skip to content

Commit

Permalink
simplify subscribe immediate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Smart committed Sep 19, 2023
1 parent 1b37a51 commit d790ad1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/rx/src/internal/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,12 @@ class RegistryImpl implements Registry.Registry {

subscribe: Rx.Rx.Subscribe = (rx, f, options) => {
const node = this.ensureNode(rx)
if (options?.immediate) {
f(node.value())
}
const remove = node.subscribe(function() {
f(node._value)
})

if (options?.immediate) {
if ((node.state & NodeFlags.initialized) === 0) {
node.value()
} else {
f(node.value())
}
}

return () => {
remove()
if (node.canBeRemoved) {
Expand Down

0 comments on commit d790ad1

Please sign in to comment.