Compact Cursor Library built on top of the excellent seamless-immutable. Cursors can be used to manage transitions and manipulations of immutable structures in an application.
A 20 minute presentation explains the utility of this library and the repository contents. Slides can be viewed here
const rootCursor = new Cursor({ users: { abby: 1, ben: 2, claire: 3, dan: 4 }, documents: [ { name: 'CV', owner: 1, mediaType: 'application/pdf' }, { name: 'References', owner: 1, mediaType: 'text/plain' } ] }); // Register a function to react to new generations of our immutable data rootCursor.onChange((nextData, prevData, pathUpdated) => { console.debug('Updated ' + JSON.stringify(pathUpdated)); }); // Create a cursor for a limited portion of our data hierarchy const childCursor = rootCursor.refine(['documents', 0, 'name']); // firstDocumentName will be 'CV' const firstDocumentName = childCursor.data; // Update -- this switches the data owned by rootCursor to point to // a new generation of immutable data childCursor.data = 'Resume'; // updatedFirstDocumentName will be 'Resume' because the cursor points // to the location, not the specific data const updatedFirstDocumentName = childCursor.data; // updatedFirstDocumentNameFromRoot will ALSO be 'Resume' because the // 'managed' data has moved to a new generation based on the prior update const updatedFirstDocumentNameFromRoot = rootCursor.data.documents[0].name;
The demo folder contains a simple demo that combines this library, seamless-immutable and React.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4