Created
May 1, 2018 15:33
-
-
Save travisrcory/12778a7574d3bd28aa125605bedc848e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Parent | |
{namespace Parent} | |
{template .render} | |
{param title: string} | |
{param _customEventListener: any} | |
{call ChildA.render} | |
{param events: [ | |
'customEvent': $_customEventListener | |
]} | |
{param ref: 'childA'} | |
{/call} | |
{/template} | |
// Parent JS | |
class Parent extends Component { | |
myFunction() { | |
console.log(this.refs) // return object containing 'childA' | |
this.refs['childA'].functionToCall(); | |
} | |
_customEventListener({someData}) { | |
// called when child emits it | |
console.log({someData}); // data passed up | |
} | |
} | |
// ChildA | |
{namespace ChildA} | |
{template .render} | |
{param title: string} | |
{/template} | |
// ChildA JS | |
class ChildA extends Component { | |
myFunction() { | |
this.emit('customEvent', {someData}); | |
} | |
_customEventListener() { | |
// called when child emits it | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment