Last active
July 14, 2017 00:19
-
-
Save Idered/c1efb7cff66b1dd634f23c6848066b60 to your computer and use it in GitHub Desktop.
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 {app} from '../helpers' | |
import MessageList from './message-list' | |
import Messages from '../mixins/messages' | |
export default () => { | |
app({ | |
mixins: [Messages], | |
view: (state, actions) => | |
<div> | |
<MessageList compose={{state, actions}} /> | |
</div> | |
}) | |
} |
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 { | |
MessageList: (state, actions) => ({ | |
messages: state.messages, | |
}) | |
} |
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 function compose(Component, composer) { | |
const ComposedComponent = ({compose}) => { | |
composer = composer || composers[Component.name] | |
return ( | |
<Component | |
{...(composer ? composer(compose.state, compose.actions) : compose)} | |
/> | |
) | |
} | |
return ComposedComponent | |
} |
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 {compose} from '../helpers' | |
import Message from '../components/message-list-item' | |
const MessageList = ({messages}) => | |
<div> | |
{messages.map(item => <Message key={item.id} {...item} />)} | |
</div> | |
export default compose(MessageList) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment