Created
February 13, 2018 12:21
-
-
Save barneycarroll/2da7600ab5b16968ba75e392559b9146 to your computer and use it in GitHub Desktop.
What's wrong with this?
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
export default (component, previous = undefined) => ({ | |
...component, | |
onbeforeupdate: (a, b) => ( | |
component.onbeforeupdate | |
&& | |
component.onbeforeupdate(a, b) !== false | |
&& | |
previous = b | |
), | |
...['view', 'onupdate', 'onbeforeremove', 'onremove'] | |
.filter( | |
key => component[key] | |
) | |
.reduce( | |
(lifecycle, key) => ({ | |
...lifecycle, | |
[key] : current => | |
component[key](current, previous), | |
}) | |
, | |
{} | |
) | |
, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment