Closed geirsagberg closed 9 years ago
The new reference API actually support passing in a cursor. See https://github.com/omniscientjs/immstruct/blob/master/src/structure.js#L206. This is not documented yet, as it is unreleased. Will hopefully be released within the month. We could also extend the API allow for references to create references, something like the code below.
Structure.prototype.reference = function reference (path) { // local function name to avoid collisions
// ...
var self = this,
cursor = this.cursor(path),
unobservers = Immutable.Set();
// ...
return {
reference: function (subPath) {
return reference((cursor._keyPath || []).concat(subPath));
},
observe: function (eventName, newFn) {
},
cursor: function (subPath) {
},
// ... etc
Note: This is untested, but something like it should work. Pull Requests with tests and docs are very welcome! :cake:
Awesomesauce :)
I want to be able to pass a reference around, and create a reference to a child cursor at a later stage, where I might not have access to the entire structure:
Any thoughts on how to accomplish this? Or, how to get a reference by passing a cursor to the structure, perhaps?