State actions - limiting actions state scope

I’m working on re-building a game using Aurelia’s State plugin. I feel I have come across an oddity. When subscribing to State, you can use Pluck to reach into the state and read something directly, but it seems that actions always get the global state.

If I wanted to add a student to a school, and my state is organized like
[District].[ZipCode].[School].[Grade].[student]
my addStudent action would need to transverse the entire path, even if the component I’m working in is already limited to the school. From https://aurelia.io/#two-way-binding-and-state-management a model is used to contain the new person, and is updated using return Object.assign({}, state, model), but this is only useful if the new person is at the base of the State.

Is there (should there?) be a way for an action to only receive and affect a specific portion of the state? Perhaps a
store.registerActionAtPath(stringId, functionCB, pluckPath)

1 Like

This is interesting.

It may come useful where you want to assign a part of your state to a specific component, whose (local) state is that part of your global state, and whose actions only return the local state, which is then be “reduxCombined” (for lack of better verb) back into the grand state.

However, I personally think that level of granularity is nice-to-have but not necessary.

1 Like