Skip to content
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

Use of @Action Decorator in Provider Class #2

Open
bastikempken opened this issue Jun 16, 2020 · 4 comments
Open

Use of @Action Decorator in Provider Class #2

bastikempken opened this issue Jun 16, 2020 · 4 comments

Comments

@bastikempken
Copy link

I'm submitting a...


[X] Feature request

Expected behavior

I thought about the feature to attach actions on class level, based on the the concept of a so called provider class. This could be designed as follows:

@State<StateModel>({ name: 'shop', defaults: DEFAULT_SHOP_STATE })
@Injectable()
export class StateClass {
   constructor(private someProviderClass:SomeProviderClass) {
       attachAction(this,someProviderClass)
   }
}

@Injectable()
export class SomeProviderClass {
    @Action(SomeAction)
    someAction(ctx: StateContext<StateModel>, action: SomeAction) { ... }
}

Within the someAction-Method the actions of the SomeProviderClass will be merged to the actions of StateClass.

What is the motivation / use case for changing the behavior?

This could be an alternative, if the user prefers familiar use of the @Action-Decorator. I'm really interested in feedback if it is worth to work on a feature request i would provide.

Thx in advance

@duffleit
Copy link
Collaborator

Hi, thanks for the feedback. I like it. We considered an option like this in the beginning of this project. We abandoned it, but I'm not sure about the reasoning anymore to be honest.

Nevertheless, please fill free to try to implement this behavior. I would just not reuse attachAction, but would introduce something new like attachActionProvider.

@bastikempken
Copy link
Author

I have created a pull request (still in progress): #4 . Thy in adavanced for feedback.

@bastikempken
Copy link
Author

@duffleit Is there a chance to complete the Pull Request soon, im highly interested in the Library and their use in one of my applications :)

@gtteamamxx
Copy link

gtteamamxx commented Nov 17, 2021

any update? @duffleit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants