Let's say we have an action in state that handles the creation of a new list:
@Action(CreateList)
async createList(
ctx: StateContext<StateModel>,
{ payload }: CreateList
) {
// Create a new list
const newList = await this._listServiceProxy
.create(payload.listId, payload.input)
.toPromise();
ctx.setState(
patch<StateModel>({
lists: append([newList])
})
);
}
And let's say we need the new ID of the created list.
Currently, the action dispatch only returns an observable that receives the new state after action completion. Fetching the last list in this scenario works, but it's not always easy to find a workaround depending on the usage.
How can I send back the created list id?