-
Notifications
You must be signed in to change notification settings - Fork 22
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
[Request] Simplify model updates #1
Comments
Hi @GregOnNet ! Please, feel free to explore this topic and please share your progress so we can discuss what would make most sense ;) |
Thank you for the first feedback. I will keep you up to date with my progress on this topic. |
Hey there, I thought about a way to implement the mutator functions. Array vs Dictionary vs CustomThe current example uses an Array-Type for the model. From my perspective, there are two possibilities.
If you find one of this proposals valuable, I am glad to provide a PR. Cheers |
Hi @GregOnNet ! |
Hey, thanks for the quick reply. At the moment different methods are provided that configure EDIT 2 export interface ModelOptions {
immuatable: boolean;
sharedSubscription: boolean;
clone: (model: T) => T;
getIdientifier: (model: T) => string|number
} I would also provide a default configuration based on the parameters which are passed in the method const defaultModelOptions: ModelOptions = {
immutable: true;
sharedSubscription: false
} In the end the API for // with default options
this.model = this.modelFactory.createWithAdapter(initialData);
// with own options
this.model = this.modelFactory.createWithAdapter(initialData, {
immutable: false,
sharedSubscription: true
}); What do you think about it. |
@GregOnNet ok but add also possiblity to pass custom clone function as in original model, else all good, thank you! |
I missed one point. That's why I need to add an option enabling the user to pass a custom selector providing the identifier of the model. export interface ModelOptions {
immuatable: boolean;
sharedSubscription: boolean;
clone: (model: T) => T;
getIdientifier: (model: T) => string|number
} |
Hey @GregOnNet ! How is it going ? Any progress on this feature? :) |
Hey @tomastrajan, I was a bit busy the last two weeks but I already started to implement the feature. |
Hey @tomastrajan, I would like to discuss one thing before I go further. From my perspective, it would be better to enforce immutable data structures using the I started to implement the adapter functions for collections and it is really hard to preserve the reference of the Array. If we agree to use immutable data structures only, I am also able to remove the methods For now, I do not really see a benefit supporting mutable data structures. What are your thoughts on this? Kinds |
Hi, I just want to mention that I am still committed to this issue. Cheers |
Hi @GregOnNet that would be great! |
Aren't we killing the purpose of minimal state management solution by adding ngrx/entity solutions? |
Thank you
Hi,
thank you for providing this library.
It is really intuitive and easy to use especially for newcomers dealing with state management.
Describe the feature you'd like:
Do you plan to enhance the
Model
-API making it easier to add, update and delete model items?The maintainers of ngrx/entity introduced an adapter for this.
I did a lot with ngrx and would be glad to help to implement this feature. :)
Other information:
Desired Methods would be
addOne
addMany
updateOne
updateMany
removeOne
removeMany
I would be willing to submit a PR to add this feature:
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
If you are willing to submit a PR but are a bit unsure, feel free to check out the Contributors Guide for useful tips and hints that help you get started.
Cheers 🍻
Gregor
The text was updated successfully, but these errors were encountered: