-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Provide way to omit __interal__ from store on get #137
Conversation
The internal key causes some problems, both during write (sindresorhus#114) and at read (can't trust MyStore.keys() or MyStore.values() without omitting __internal__). We should at least export the variable so the client can manually omit it (and at best, provide a more ergonomic pattern—perhaps a WeakMap?)
In my subclass, I do this: public get current(): T {
return omit(this.store, "__internal__") as T
}
public set current(value: T) {
const { __internal__ } = this.store
this.store = {...value, __internal__ } as T
} which seems to work but isn't ideal (and at the very least, I'd love import INTERNAL_KEY rather than hardcode it here). |
I'm not interested in exposing internal implementation details. This should be properly fixed by making changes to |
Cannot use |
fair enough. do you think the changes to the getter/setter goes beyond what I did in my subclass? |
I think that should be enough as |
should I submit a PR with this change? |
Yes, that would be great. Needs some tests too. |
It's unfortunately not going to be super simple as migrations (or at least their tests) rely on being able to lookup migrations by the internal property (for example this, relies on .get() which in turn uses .store). I'm not sure your preferred strategy for exposing/mocking private methods for tests, but if you're willing to remove the ability to .get() data off the internal key, we could introduce some kind of method _getInternal() that doesn't use .get store, though in order to use it in the tests it'd have to be public... |
We could also do some |
Sounds good. We can make it public only when |
Friendly bump :) |
Closing for lack of activity. |
The internal key causes some problems, both during write (#114) and at read (can't trust MyStore.keys() or MyStore.values() without omitting internal). We should at least export the variable so the client can manually omit it (and at best, provide a more ergonomic pattern—perhaps a WeakMap?)