fred is a functional reactive editor designed for dynamic and structured
data manipulation using cells as a
runtime. fred leverages functional reactivity to track and manage updates in
data structures like arrays, objects, and dictionaries.
Define a schema using LabelledTypeDefinition to specify structure,
validation rules, and properties of the data.
fred models data as a graph of nodes that can represent objects, arrays, or
dictionaries. Each node tracks its state reactively.
fred provides operations like adding/removing elements, modifying
properties, and updating dictionaries in a reactive manner.
Let's see an example that includes both an object and an array.
import{Sheet,SheetProxy}from"@okcontract/cells";import{DataEditor,newSchema,objectDefinition}from"@okcontract/fred";constsheet=newSheet();constproxy=newSheetProxy(sheet);// Initialize reactive dataconsttestArray=proxy.new([],"test");constdata=proxy.new({test: testArray},"data");// Define schema using helpersconstvalues=objectDefinition(proxy,{test: {label: "Test",array: ()=>proxy.new({label: "Test Item",base: "string",}),},});constschema=newSchema(proxy,values);consteditor=newDataEditor(proxy,data,schema);// Add an element to the arrayconstarrNode=awaiteditor.follow(["test"]);awaiteditor.addElement(arrNode);awaitproxy.working.wait();// Verify the new stateconsole.log(awaitproxy.get(arrNode.value));// [{}, "", ...]We aim for ease of use, correction and security, so chasing down any bug is our top priority.
A non-goal is high-performance.
fred is built at OKcontract and is released under
the Apache license.
Contributors are welcome, feel free to submit PRs directly for small changes. You can also reach out on Twitter in advance for larger contributions.
This work is supported in part by a RFG grant from Optimism.