-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove createPureProduct in favor of pure No need to create multiple pureProduct, only one is required - Talent are now called with the product they will output It looks a bit like a constructor with this set to the created object so that you got a pointer on it - Restore valueOf on product passed to talent We need a pointer to the talentedProduct in many case. - Product are now frozen objects Cannot add new properties Cannot reconfigure existing properties - Much more documentation - One talent per product This is an implementation detail but now a product does not hold a list of talent
- Loading branch information
Showing
10 changed files
with
275 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Talent | ||
|
||
A talent is a function that should | ||
|
||
* read properties from argument using param destructuring | ||
* write properties returning an object | ||
|
||
```javascript | ||
// wrong | ||
const talentWithoutPattern = (product) => { | ||
product.value++ | ||
} | ||
|
||
// right | ||
const talentWithPattern = ({ value }) => { | ||
return { | ||
value: value + 1, | ||
} | ||
} | ||
``` | ||
|
||
## Talent pattern advantages | ||
|
||
* Destructuring param shows in a glimpse what you talent needs to read | ||
* Returned object show in a glimpse what you talent needs to write | ||
* Destructuring param prevent temptation to mutate talent argument (the product) | ||
* Returned object is internally used to set non configurable and non writable properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.