Support storing shallow objects as part of the deepsignal#38
Conversation
|
Size Change: +109 B (+2%) Total Size: 6.49 kB
|
|
@wittjosiah, I haven't figured out the TypeScript part yet, but I've released this with a different tag so you can test it out and let me know what you think: https://www.npmjs.com/package/deepsignal/v/1.4.0-shallow.0 |
wittjosiah
left a comment
There was a problem hiding this comment.
@luisherranz works great on our end from my initial test. If we run into any issues with it I'll let you know and I'll keep an eye out for this to come in a release. Thanks for tackling this 🙂
|
Thanks @wittjosiah. |
|
I have some concerns about the code in this pull request: the |
|
Well, I might have misunderstood the "shallowing" mechanism: it seems to ignore complete objects only - not just properties. Even in the case |
|
When you mention "I haven't figured out the TypeScript part yet", does this refer to the type returned by This is what I see, but I'm not sure I am implementing it correctly. store.state.categoryLookup = shallow(
new CategoryLookup(categories),
) as DeepSignal<CategoryLookup>; // Have to cast as shallow is returning <CategoryLookup>Perhaps I am setting the state's property incorrectly, since it is an object versus a primitive? |
Yes, that's it. You need to use
Yes, that's how it works and hence the name "shallow": it will only observe the reference to that object, but not the object itself.
It's not a |
| @@ -0,0 +1,10 @@ | |||
| { | |||
There was a problem hiding this comment.
This file will be removed once we publish the next version, no need to take care of it manually.
|
I'm happy with TypeScript now. I've also removed the |
DAreRodz
left a comment
There was a problem hiding this comment.
Looks great, @luisherranz! 👏
PS: I've only seen a couple of odd TS tests.
What
Fixes #36.
Support storing shallow objects as part of the deepsignal with
shallow.It accepts this signatures:
Why
To prevent deepSignal from deep observing objects that don't need to be observed.
How
By exposing a
shallowfunction that adds references to theignoreset used by theshouldProxyfunction.