April 2020
Intermediate to advanced
292 pages
6h 50m
English
Arrow functions give us a shorthand for defining functions that we use mostly when defining inline functions. Here is an example of one from the book, taken from the identity component’s handlers:
| | return { |
| | Register: command => { |
| | const context = { |
| | messageStore: messageStore, |
| | command, |
| | identityId: command.data.userId |
| | } |
| | |
| | return Bluebird.resolve(context) |
| | .then(loadIdentity) |
| | .then(ensureNotRegistered) |
| | .then(writeRegisteredEvent) |
| | .catch(AlreadyRegsiteredError, () => {}) |
| | } |
| | } |
We’re defining an object literal with key Register whose value is a function. This function takes one parameter, namely command. Previously we would have had to write this function ...
Read now
Unlock full access