-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add Deep Whitelists & Blacklists #27
Comments
How about using something like Ramda's |
That could be an option too. The array piece is still a bit confusing either way |
Without proper deep blacklisting and debouncing, the package uses a lot of resources and it's unusable in production for large apps. I suggest directly using an object to blacklist variables instead of passing a string array and convert it using For example if the state tree is structured as this: const store = types.model({
book: types.model({
release: types.Date,
authors: types.array(Author)
}),
user: types.maybe(SomeUserModel)
})
const Author = types.model({
name: types.string,
age: types.number
})
const SomeUserModel = types.model({
... ,
...
}) blacklisting can be done as following: const blacklist = {
book: {
release: false,
authors: [{
name: true,
age: false
}]
},
user: true
} Notes:
|
To explain the algorithm for my suggested solution, we go through the
|
Maybe if someone wanna find a temporary solution, I suggest save deep store/properties as as example: Store, that will be nested in another store RemindersStore.model('RemindersStore', {
allowed: true,
date: new Date(),
days: ['monday', 'friday']
}) Store, that will be parent for nested store ProfileStore.model({
reminders: RemindersStore,
anotherProp: true
}) Flow to save deep properties for nested store: const profilesStore = ProfileStore.create({
reminders: RemindersStore.create()
})
persist('profileStore', profilesStore.reminders, {
whitelist: ['reminders', 'anotherProp'],
})
persist('profileStoreReminders', profilesStore.reminders, {
whitelist: ['allowed', 'date', 'days'],
}) Tested with various cases, works as expected, also if you remove some properties of parentStore ( Maybe @agilgur5 can describe better solution or reject mine |
Go multiple levels deep with whitelists and blacklists. Right now you can only go one level deep, which misses a good number of use cases. So instead of just
manga
, could domanga.release
too.The dotted syntax makes sense to me, though not sure how to handle something like an array... just implement on all elements? Or require a more explicit
[].
or something?This has popped up in agilgur5/react-native-manga-reader-app#27 and #26 .
Should really be implemented on top of Transforms #16 , but probably should be the default behavior too, not a separate transform.
The text was updated successfully, but these errors were encountered: