Skip to content
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 nesting work for newly added child observables #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

egasimus
Copy link

Suppose you create an ObservStruct and then decide to add more observable keys to it at some later point. Well, since all the nice magic only happens on initialization, that doesn't really work. For example, if you do something like:

foo = Observ("foo")
bar = Observ("bar")
baz = ObservStruct({ foo: foo })
baz.set(extend(baz(), { bar: bar }))

then baz() would return { foo: "foo", bar: [Function: observable] } rather than { foo: "foo", bar: "bar" }; and baz.bar would also remain undefined rather than becoming a proper reference to bar.

That behavior was getting in my way -- I'm putting together a simple observable key-value store for individually observable models, to serve as a state container for my app which involves a lot of user-created instances of said models -- so I had a stab at fixing it. Let me know what you think?

@Raynos
Copy link
Owner

Raynos commented Dec 26, 2015

@egasimus

Have you considered using https://github.com/nrw/observ-varhash ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants