gt3 / react-circuit Goto Github PK
View Code? Open in Web Editor NEWReact-friendly interface to CSP channels
License: MIT License
React-friendly interface to CSP channels
License: MIT License
Circuit should call props.children (factory) to return {renderApp, transport, services}
will make Circuit's api more manageable
note - revised #16
Wrap message handlers to call props.setState and pass the message handler to it.
pass (parent) context in Circuit to bootstrap
useful in inherited class to wrap and update state implicitly
pass next, err to pollThenTap
use wrap unwrap from Utils to manage state
write helper omitKeys function to remove "actions" key from source:s before calling deriveHandlers
process handler, publisher and result handler
use alts with timeout channel to abandon current request, move to next one, and report timeout error
Circuit and Result should have same context
setResult should pass (props, context) as last 2 args to handler
use firstElem to restrict property check on object and its prototype
since selectors are called during Circuit render,
Process.shouldComponenUpdate -> false (always)
Process. render -> null (always)
use in Process, Result, utils
class C {
increment = handler
//methods will work too: increment(...args) { return handler(...args) }
}
don't need props
setState mapper, render mapper
supply services, foundation as context types
compare message values instead of message wrapper -- use unwrapState before calling React's shallowCompare
pull out wrapHandler of the component class and refactor deriveHandlers
subscribe = {...handlers}
(verb in place of noun)
use class-based inheritance with Result same as Process
Result: createRefs, subscriber
Process: createRefs, beginPolling
try reading inlet, outlet from instance properties to allow context override
refHandler might need to call services, or access transport
same for selectors during render
accept handlers prop, only do checkSubd if prop.handlers does not exist
we have updated app state, we can publish now - via publisher
use Message.pass to wrap, msg.value to unwrap
will require a wrapper on updater
use naming convention to derive error handlers with process handlers - add suffix: "Errors" to handler name
also set hot=this .. derived component can just call this.setState({} or () =>
in transport, more intuitive
use shallowCompare instead of PureComponent
render child with only 2 arguments (appState, prevAppState)
this should help getting handlers defined as getter on class prototype
createTransport will only accept two params {createIntake,createOuttake}
then return {intake, outtake}
make Process component that will be eventually extended by user defined process components
intake: { ...channels, actions: { ...createActions } }
outtake: { ...channels, actions: { ...createActions }, subscribe: { ...createSubscriptions} }
do not override existing actions, subscribe
also export createActions
, createSubscriptions
don't need props
a mix of Result and Processs, in that -
like Process subscribes to intake channel, but calls registered handler w/o wrapping it in renderApp
like Result in that it does not have a publisher
unlike Result or Process, in that - does not care about component state or app state
gives destructuring convenience in method signatures
handler(props, state) => handler({configKey}, {[configKey]: val})
rather than blocking the in channel by stuffing it
if function is provided pass context as arg
use props.initialResult to call setResult during willMount in Result component
should be easier than using proxy channels
just pass appState in wrapState, no need for root/app props
pass an array of handler functions to beginPolling
renderCircuit takes a selector argument
selector gets called in Circuit render
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.