Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@nodl/react
Advanced tools
A React-implementation of the Nodl framework.
This library is powered by MobX under the hood; and may be observed by an external MobX-instance for UI reactivity.
# Using NPM
npm install @nodl/core @nodl/react
# Using Yarn
yarn add @nodl/core @nodl/react
# Using Bun
bun install @nodl/core @nodl/react
Make sure to also install the following packages:
# Using NPM
npm install react react-dom rxjs zod
# Using Yarn
yarn add react react-dom rxjs zod
# Using Bun
bun install react react-dom rxjs zod
The fundamental piece which renders a surface with fully interactive Nodes & Connections.
Supports the following props:
store: CircuitStore
A Circuit store which holds the internal circuit state along with associated nodes.className?: string
An optional className to assign the Circuit.nodeWindowResolver?: (node: Node) => JSX.Element
An optional function which can be used to render a custom "window" for given nodes.onConnection?(connection: Connection<unknown>)
An optional callback which fires when new connections are made.onConnectionRemoval?(connection: Connection<unknown>)
An optional callback which fires when connections are removed.onNodeRemoval?(node: Node)
An optional callback which fires when nodes are removed.onSelectionChanged?(nodes: Node[])
An optional callback which fires when selected nodes changes.const store = new CircuitStore();
store.setNodes([
[additionNode1, { x: -220, y: 100 }],
[additionNode2, { x: -220, y: -100 }],
[additionNode3, { x: 220, y: 0 }]
]);
export const App = () => {
return <Circuit store={store} />;
};
The manager which is responsible for the circuit state.
nodes: Node[]
The associated nodes.selectedNodes: Node[]
The currently selected nodes.selectionBounds: Bounds | null
The current selected area's bounds.mousePosition: MousePosition
Current mouse position within the Circuit surface.setNodes(nodesWithPosition: [Node, {x: number, y: number}][])
Used to initialize the store with nodes along with their position.removeNode(nodeId: Node['id'])
Removes a node from the store.selectNodes(nodes: Node[])
Selects the given nodes.dispose()
Disposes the store and its internal reactions.import { Node, Input, Output, schema } from '@nodl/core';
import { Circuit, CircuitStore } from '@nodl/react';
import * as React from 'react';
import { combineLatest, map } from 'rxjs';
import { z } from 'zod';
/** Declare a zod schema for value validation */
const NumberSchema = schema(z.number());
class Addition extends Node {
name = 'Addition';
inputs = {
a: new Input({ name: 'A', type: NumberSchema, defaultValue: 0 }),
b: new Input({ name: 'B', type: NumberSchema, defaultValue: 0 })
};
outputs = {
output: new Output({
name: 'Output',
type: NumberSchema,
observable: combineLatest([this.inputs.a, this.inputs.b]).pipe(
map(inputs => inputs.reduce((sum, value) => sum + value), 0)
)
})
};
}
/** Declare 3 addition nodes */
const additionNode1 = new Addition();
const additionNode2 = new Addition();
const additionNode3 = new Addition();
/** Connect them together */
additionNode1.outputs.output.connect(additionNode3.inputs.a);
additionNode2.outputs.output.connect(additionNode3.inputs.b);
const store = new CircuitStore();
store.setNodes([
[additionNode1, { x: -220, y: 100 }],
[additionNode2, { x: -220, y: -100 }],
[additionNode3, { x: 220, y: 0 }]
]);
export const App = () => {
return <Circuit store={store} />;
};
FAQs
React implementation of the Nodl framework
The npm package @nodl/react receives a total of 35 weekly downloads. As such, @nodl/react popularity was classified as not popular.
We found that @nodl/react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.