Skip to content

Use of @Action Decorator in Provider Class #2

@bastikempken

Description

@bastikempken

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions