Creates a new realm.
the initial cell values that will populate the realm. Those values will not trigger a recomputation cycle, and will overwrite the initial values specified for each cell.
Creates or resolves an existing cell instance in the realm. Useful as a joint point when building your own operators.
the initial value of the cell
true by default. Pass false to mark the signal as a non-distinct one, meaning that publishing the same value multiple times will re-trigger a recomputation cycle.
optional, a reference to a cell. If the cell has not been touched in the realm before, the realm will instantiate a reference to it. If it's registered already, the function will return the reference.
a reference to the cell.
Convenient for mutation of cells that contian non-primitive values (e.g. arrays, or objects). Specifies that the cell value should be changed when source emits, with the result of the map callback parameter. the map parameter gets called with the current value of the cell and the value published through the source.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a single node that emits an array of the latest values of the nodes.
When one of the source nodes emits a value, the combined node emits an array of the latest values from each node.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
Combines the values from multiple nodes into a cell that's an array of the latest values of the nodes.
A low-level utility that connects multiple nodes to a sink node with a map function. Used as a foundation for the higher-level operators. The nodes can be active (sources) or passive (pulls).
The projection function that will be called when any of the source nodes emits.
Optional
pulls?: NodeRef<unknown>[]The nodes which values will be pulled. The values will be passed as arguments to the map function.
The sink node that will receive the result of the map function.
The source nodes that emit values to the sink node. The values will be passed as arguments to the map function.
Gets the current value of a node. The node must be stateful.
if possible, use withLatestFrom or combine, as getValue will not create a dependency to the passed node, which means that if you call it within a computational cycle, you may not get the correct value.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Gets the current values of the specified nodes. Works just like getValue, but with an array of node references.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Creates a new node that emits the values of the source node transformed through the specified operators.
Explicitly includes the specified cell/signal reference in the realm. Most of the time you don't need to do that, since any interaction with the node through a realm will register it. The only exception of that rule should be when the interaction is conditional, and the node definition includes an init function that needs to be eagerly evaluated.
Creates or resolves an existing signal instance in the realm. Useful as a joint point when building your own operators.
true by default. Pass false to mark the signal as a non-distinct one, meaning that publishing the same value multiple times will re-trigger a recomputation cycle.
optional, a reference to a signal. If the signal has not been touched in the realm before, the realm will instantiate a reference to it. If it's registered already, the function will return the reference.
a reference to the signal.
Subscribes exclusively to values in the referred node.
Calling this multiple times on a single node will remove the previous subscription created through singletonSub
.
Subscriptions created through sub
are not affected.
a function that, when called, will cancel the subscription.
Subscribes to the values published in the referred node.
the cell/signal to subscribe to.
the callback to execute when the node receives a new value.
a function that, when called, will cancel the subscription.
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Subscribes to multiple nodes at once. If any of the nodes emits a value, the subscription will be called with an array of the latest values from each node. If the nodes change within a single execution cycle, the subscription will be called only once with the final node values.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const trigger$ = Signal<number>(true, (r) => {
r.link(r.pipe(trigger$, map(i => `foo${i}`)), foo$)
r.link(r.pipe(trigger$, map(i => `bar${i}`)), bar$)
})
const r = new Realm()
r.subMultiple([foo$, bar$], ([foo, bar]) => console.log(foo, bar))
r.pub(trigger$, 2)
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
Works as a reverse pipe. Constructs a function, that, when passed a certain node (sink), will create a node that will work as a publisher through the specified pipes into the sink.
const foo$ = Cell('foo')
const bar$ = Cell('bar')
const entry$ = Signal<number>(true, (r) => {
const transform = r.transformer(map(x: number => `num${x}`))
const transformFoo$ = transform(foo$)
const transformBar$ = transform(bar$)
r.link(entry$, transformFoo$)
r.link(entry$, transformBar$)
})
const r = new Realm()
r.pub(entry$, 1) // Both foo$ and bar$ now contain `num1`
The realm is the actual "engine" that orchestrates any cells and signals that it touches. The realm also stores the state and the dependencies of the nodes that are referred through it.