Dagify 2.0 reshapes the public surface to focus on a lightweight, FRP-friendly core. This guide highlights the notable changes and how to update existing code.
- The root
dagifyexport now exposes only the core building blocks (createNode,createGraph,createComposite, batching helpers, FRP utilities, etc.). - Advanced utilities (bridge, command, sink, shallow nodes, encoding, types) live under dedicated subpaths.
| 1.x Import | 2.0 Replacement |
|---|---|
import { createBridgeNode } from "dagify"; |
import { bridge } from "dagify/effect"; |
import { createCommandNode } from "dagify"; |
import { command } from "dagify/effect"; |
import { createShallowNode } from "dagify"; |
import { createShallowNode } from "dagify/shallow"; |
import { nodeFactory } from "dagify"; |
import { nodeFactory } from "dagify/node"; |
The legacy paths remain temporarily for compatibility, but new code should use the scoped modules.
New helpers encapsulate common stream transformations:
map,filter,combine,merge,switchLatestfrom(wraps promises or observables as nodes)createStore(alias for a simple stateful node)- Every node now exposes
.streamfor plug-and-play observable interop.
Example
import { createStore, map, filter, combine } from "dagify";
const counter = createStore(0);
const doubled = map(counter, n => n * 2);
const even = filter(doubled, n => n % 2 === 0);
even.stream.subscribe(value => console.log(value));
counter.set(1); // filtered out
counter.set(2); // logs 4Side-effect oriented utilities are grouped under dagify/effect:
import { effect } from "dagify/effect";
const cmd = effect.command("@user/update", payload => payload);
const bridgeNode = effect.bridge(inputNode, outputNode);
const sinkNode = effect.sink(value => console.log(value));
const eventNode = effect.fromEvent("socket/data");The namespace also re-exports trigger, createTrigger, and the shared dispatcher.
ReactiveNodenow exposes a.streamgetter (alias oftoObservable()).fromObservableaccepts an optional config object that is passed to the underlyingReactiveNode.- FRP helpers default to
NO_EMITuntil a source emits—be mindful when asserting initial values in tests.
- Update imports to use the scoped modules.
- Replace manual observable plumbing with the new FRP helpers where it simplifies code.
- If you consumed effect utilities from the root entry, migrate them to
dagify/effect. - Run the updated test suite to confirm behavior (
npm test).
For any issues, please open a GitHub issue with reproduction steps. Happy migrating!