Skip to content

🚀[FEATURE]: Add option to specify Lifecycle Point to @Action() decorator #488

Description

@rweng

It would be handy to do s.th. like this:

class MyState {
  @Action(SyncDatabase)
  syncDatabase(ctx){ ctx.patchState({isSyncing: true}) }

  @Action(SyncDatabase, {on: 'SUCCESSFUL'})
  onSyncDone(ctx, action) { ctx.patchState({isSyncing: false}) }
}

I am not sure how exactly the API should look like, or whether it would also be useful to add another lifecycle hook for completed. Also, it would be handy to have to result of the Promise / Observable on the action.

I know it is possible to subscribe to the action stream and do this manually and this is just syntactic sugar. However, I feel like this would be a nice addition since for me it is more readable than having subscriptions on the action stream while at the same time reducing Action definitions (e.g. a separate SyncDatabaseDone).

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions