New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make immstruct instantiable? #10
Comments
Do you mean something like the following? var Structure = require('immstruct/src/structure');
var structure = new Structure({
data: myImmutableOrNotData
}); |
I was thinking of just |
I don't quite understand. Do you want to be able to create an instance of the "instance manager"? |
Yep. This is my use case: var immstruct = require('immstruct');
var chest = new immstruct();
var meta = new immstruct();
var structure = chest({ a: { b: { c: 1 } } });
var metaStructure = meta(structure.key); |
This is a drastic change in API. So I'm throwing ideas around. |
Is it essential that they share key? Or could you just do var immstruct = require('immstruct');
var structure = immstruct({ a: { b: { c: 1 } } });
var metaStructure = immstruct(structure.key + 'meta'); It doesn't need to be the biggest API-change, though. Could rewrite the internals to be a instancable, and expose something like: module.exports = new Immstruct();
module.exports.Immstruct = Immstruct;
// Some other file:
var Immstruct = require('immstruct').Immstruct;
new Immstruct(); |
It's not absolutely essentially that they share keys; but I use it to match each other in a map. I've thought about At the moment, I'm keeping track of Structure instances externally. But eventually I'd like to delegate this to just immstruct. |
This is what I don't really get. immstruct-factory is a way to keep track of Structure, why would you do this externally? To share keys? Maybe I'm a bit slow today 😴 |
I just didn't want to pollute the To clarify, the external Structure instances I'm talking about are the ones being instantiated externally; not via |
Fixed in 84a35e1 |
Usage is var local = new immstruct.Immstruct(); Default usage (without own instance) remains the same as before. |
Awesome thanks. |
I'm mulling over an idea to make immstruct instantiable. Pretty much in the same manner that
EventEmitter
is instantiable.I'm suggesting this so that something like
new immstruct().instances
would be compartmentalized. I have a library that's a work-in-progress that decorates theimmstruct
, and one feature I have is that it creates an associated meta-structure for a given immstruct structure.The text was updated successfully, but these errors were encountered: