Created
August 17, 2016 18:43
-
-
Save WreckedAvent/da00b87202c9d9629fae9b3bbe80b072 to your computer and use it in GitHub Desktop.
code flow.js
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
import * as m from 'mithril' | |
export const controller = function(props) { | |
var self = this | |
this.myAction = msg => { | |
event.preventDefault() | |
// HERE I WANT TO SEND THE 'smg' TO THE 'ctrl.message' ON MainComponent. | |
props.message('set to whatever!') | |
} | |
} | |
export const view = (ctrl, props) => [ | |
m('h3', 'Option List'), | |
m('.list_items', [ | |
props.items.map(item => | |
m('a', { | |
href: '#', | |
onclick: () => ctrl.myAction(item.msg) // could also just do props.message(item.message) directly and drop the controller entirely | |
}, item.name) | |
) | |
]) | |
] |
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
import * as m from 'mithril' | |
import * as ChildComponent from './child' | |
export const controller = function() { | |
this.message = m.prop('An example here') | |
this.items = [ | |
{name: 'test1', msg: 'message test 1'}, | |
{name: 'test2', msg: 'message test 2'}, | |
{name: 'test3', msg: 'message test 3'}, | |
{name: 'test4', msg: 'message test 4'}, | |
{name: 'test5', msg: 'message test 5'}, | |
] | |
} | |
export const view = ctrl => [ | |
m('h1', ctrl.message() ? ctrl.message() : ''), | |
m(ChildComponent, { message: ctrl.message, items: ctrl.items }) | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment