Make actions serializable #591
Labels
5
backlog
Proposals or issues to be fixed in the future
enhancement
New feature or request
refactor
sdk 🖥
Description
We need serializable actions. Usually, it's not expected actions to need to be serialized, nor go in state, but it's useful for one specific usecase: pending actions that have a confirmation counterpart, and we need to be able to recover in case client is closed between both.
The action creator implementation should use
io-ts
, our codec/validation library of choice, and be self-contained (no multiple places of declarations to add a new action). It must also be type-safe and implement the FSA pattern (actions being plain objects containg onlytype
,payload
,meta
&error
properties).From this, it'd be interesting if the Acion Creator itself was the codec instance, so members can be accessed directly, but it may not be practical to do it over the callable function needed for the action creator. If this is the case, the codec can be defined as a
codec
property.It may replace or extend our typesafe-actions dependency, may have an interface similar to it (to minimize changes), but ideally replace standalone utilities (ActionType,
getType
,isActionOf
, etc) with methods/member functions in the action creator object itself.A generic
Error
serialization codec is needed for the error actions, like serialize-error but typesafe and compatible withio-ts
. No need for strong guarantees on the types, as they're mostly informative in the SDK.Acceptance criteria
payload
&meta
membersthis
unbind) of the AC which checks onlytype
literal instead ofcodec.is
which validates recursivelytype
types are exposed as well; a standaloneActionType
generic can also be exposed to calculate this in a standalone wayTasks
The text was updated successfully, but these errors were encountered: