i have type this:
declare type relation = { _id?: string, root : string, oprimary :string, nodes : [ontology]
}
declare type ontology = { id : string, ont : string[] }
and in reducer, have state defined this:
export interface relatedbusinessstate { relation : relation
}
my components update fields in document, inserting or removing node.the data stored in mongo db, , reading , writing db done in @effect via call service.
i prefer not update whole document every time there small change, @addtoset or similar. @effect needs know enough selector, , specific fields need change.
what best way set state in reducer function? state observable changes reflected in subscriber. if add key in object, edit : {_id : thisid,...} typescript errors in @effect function property 'edit' not exist on type relation.
the @effect saves data , gets updated document, dispatching update_complete reducer function updates state.
edit: i'll try clarify. there may not issue @ except misunderstanding. here goes.
i'm subscribing state, , component , view update when state changed in reducer.
my backend data storage requires changed data update document in collection.
the nodes , ontologies changed , in component; adding or removing something. want view reflect change quickly.
so action call in component this, addnode function dispatches action.
addnode({ id : token, ont : ['customer']});
the action creator this:
static add_node = '[relations] add node'; addnode(node : ontology) : action { return { type : relatedbusinessaction.add_node, payload : node } }
the @effects database calls made.
@effect nodeadd$ = this.updates$ .whenaction(relatedbusinessactions.add_node .map<relation>(topayload)
my question topayload return? return updated state set in reducer, or return payload of action?
my question topayload return? return updated state set in reducer, or return payload of action?
it's return action.payload.
export function topayload(action: action) { return action.payload; }
Comments
Post a Comment