September 2017
Intermediate to advanced
216 pages
6h 8m
English
If you could pass arguments to the behavior that gets invoked when you call your behavior functions, it would be nice. This would mean that your behavior function would have to forward the arguments that it receives to the functions that it looks up from the behavior map:
const log = value => console.log('log:', value);const myBehavior = (action, ...args) => Map.of( 'start', value => log(`starting ${value}...`), 'stop', value => log(`stopping ${value}...`)).get( action, () => {})(...args);myBehavior('start', 'database');// -> log: starting database...myBehavior('start', 'server');// -> log: starting server...myBehavior('stop', 'database');// -> log: stopping database...myBehavior('stop', 'server');// -> log: ...Read now
Unlock full access