You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
constrootCursor=newCursor({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 datarootCursor.onChange((nextData,prevData,pathUpdated)=>{console.debug('Updated '+JSON.stringify(pathUpdated));});// Create a cursor for a limited portion of our data hierarchyconstchildCursor=rootCursor.refine(['documents',0,'name']);// firstDocumentName will be 'CV'constfirstDocumentName=childCursor.data;// Update -- this switches the data owned by rootCursor to point to// a new generation of immutable datachildCursor.data='Resume';// updatedFirstDocumentName will be 'Resume' because the cursor points// to the location, not the specific dataconstupdatedFirstDocumentName=childCursor.data;// updatedFirstDocumentNameFromRoot will ALSO be 'Resume' because the// 'managed' data has moved to a new generation based on the prior updateconstupdatedFirstDocumentNameFromRoot=rootCursor.data.documents[0].name;
React Demo
The demo folder contains a simple demo that combines this library, seamless-immutable and React.
About
Compact Cursor Library built on top of the excellent seamless-immutable