Sometimes, we need to "mirror" a specific state objects directly, without another state object to base results of. This is where "state reflection" comes into play.
It's exactly the same as state mirroring (see #1), though the difference is that we are directly reflecting a state object value, instead of mirroring it via absorbing its value.
I.e:
local state = hold(100, Vinum.JustOk)
local reflectedState = Reflect(state) -- all changes transmitted to state will also be sent to reflectedState
reflectedState:set(13) -- errors, and the set method doesn't exist at all
As you can see, state reflection can be used to create a reflected version of a state object that is publicly immutable.
Sometimes, we need to "mirror" a specific state objects directly, without another state object to base results of. This is where "state reflection" comes into play.
It's exactly the same as state mirroring (see #1), though the difference is that we are directly reflecting a state object value, instead of mirroring it via absorbing its value.
I.e:
As you can see, state reflection can be used to create a reflected version of a state object that is publicly immutable.