-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
How to deal with breaking change #7
Comments
hi there! ... some thoughts I have on this: so the following needs to be changed with NgRx Ducks 9, is that correct?
In theory it should be possible using schematics I guess, maybe we have to collect all another path for such a migration could be a lint rule with an option for a fix, and then execute the linter using the
I don't have that much experience with AST and/or lint rule fixes, but this sounds very interesting and challenging ... What do you have in mind? Do you think that the lint rule could be a simple solution? |
Good morning, I need to read your comment a bit more in detail today but the first few lines are absolutely correct. Simpler, breaking-change-free APIDefinitionimport * as selectors from './selectors.ts';
@InjectableSlice<T>({
initialValue: {},
providedIn: Module // check if exposing the injectable API adds benefit in terms of the initial bundle size
})
export class MySlice {
select = bindSelectors(selectors);
load = bindAction('Action without payload');
search = bindAction<QueryParams>('Action having a payload');
loadSuccess = bindAction(
'action taking a case reducer',
(slice: T, payload: TPayload) => {
return { ...slice, payload }
}
);
}
export const reducer = reducerFrom(MySlice);
export const actions = actionsFrom(MySlice); Usage@Component(/* ... */)
export class MyComponent {
constructor(private slice: Slice<MySlice>) {}
}
|
//cc @Markus-Ende |
@skydever I really like the idea having tslint in place. We can have a look into it. It would be enough to use JSDoc and deprecate the "old" API (It is not that old actually... 🤣). My basic intention is not to break anyone if it is not needed but I want keep improving the API little by little. |
I like the new api 🎉 and an automated migration would be awesome, beside the possibility to still use the old one for now 👍 |
Thank you so much for the feedback. |
I also like this API, it feels more intuitive to have all those bind functions, especially the merged bindAction for Why the rename from |
For now, there are 3 reasons:
|
I think the propsed API would be much clearer then the current one. The ditinction of effects and actions and the resulting As I just stumbled upon difficulties using selectors with parameters (see #8) I think the new API should support that as well. |
one more thing I have to add, maybe this is the right place ... I was using static fields/methods at my Ducks to simplify the StoreModule.forFeature(MyDuck.featureName, MyDuck.reducer) and I was also using the createFeatureSelector<MyState>(MyDuck.featureName) but this seems not to be possible anymore (I am [very late] updating all my deps. at the moment). Do you think it is a bad idea to do it like this, and why? ... and another thing, it would be great to inherit the Duck from a base class that has some reusable logic, eg. the creation of the Thank you! |
Hi Thomas, sorry that the current version breaks you code. A Duck does not match to a feature but to a slice living in a feature. Concerning |
Hi @GregOnNet Thx for the fast reply, I already adopted the code 👍
Maybe I missed something (I started using With the new API it should be possible to create a base Duck that contains all CRUD methods as actions (using a protected |
I think it would be great if there are no restrictions, even DI into a Duck class... in my opinion this would enhance the Ducks a lot ... |
... maybe there is a better functional programming approach, but in terms of classes and inheritance this would be awesome ... |
I will take everything into account. Thanks for your input. Concerning entity adapter. What do you think about the following API. class EntityAdapter {
addOne() {}
addAll() {}
addMany() {}
// ...
}
@InjectableSlice({})
export class MySlice extends EntityAdapter {
loadSuccess = bindAction(
'action taking a case reducer',
(slice: T, payload: TPayload) => {
return addOne(payload, slice)
}
);
} |
@skydever I now remember that we discussed the EntityAdapter a bit differently before. |
The progress of the |
@GregOnNet yes, that was the idea back then - I also created a |
Closing this issue, for now. |
In NgRx Ducks 9 a Breaking Change is about to be introduced in order to align the API.
Methods annotated with
Action
are not dispatched anymore.They will just be plain action creators.
In order to dispatch an action
dispatch
needs to be called.This is like
effect
already behaves.In this issue I want to discuss if there is an easy way to provide an automatic migration path, or if a kind of other API should be introduced making it possible using the old and the new API in parallel.
The text was updated successfully, but these errors were encountered: