-
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.
add a semi-awkard api for calling back the props in the child component. TODO: - let the child component specify the propTypes that it will call any callback with - let the child specify whether providing the callback is optional or not (or just rely on propTypes? probably...) There are two levels toward ease-of-typing that this can move toward. Currently, you do: ```js Update({ cb: { onAdd: [task] }, }); ``` We need the wrap the payload in an array so that we can apply to the callback with whatever number of arguments are required. So we could hack this structure with only an array instead: ```js Update({ cb: ['onAdd', task], }); ``` Which is a little ugly and feels to string-y, but is maybe a little less error-prone on the array-wrapping We could go full react: ```js Update({ onAdd: [task], }); ``` which, damn, is sort of nice to type and read. But also... namespacing, magic, ugh ugh. I'm sticking with the explicit nested-object version for now. The array-wrapping could either be totally gross and allow an unwrapped payload for single-arg callbacks (which _is_ by far the most common case), or at least have a useful error message for an unwrapped payload that would be annoying, but easy to debug. --- Onnnnnn the parent side, using regular react-style prop callbacks is wonderful. Not having to import ChildEmit to switch over different emit payload types is way better. This feels really right.
- Loading branch information
Showing
8 changed files
with
39 additions
and
50 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
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
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