Skip to content

Instantly share code, notes, and snippets.

@Idered
Last active July 14, 2017 00:19
Show Gist options
  • Save Idered/c1efb7cff66b1dd634f23c6848066b60 to your computer and use it in GitHub Desktop.
Save Idered/c1efb7cff66b1dd634f23c6848066b60 to your computer and use it in GitHub Desktop.
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>
})
}
export default {
MessageList: (state, actions) => ({
messages: state.messages,
})
}
export function compose(Component, composer) {
const ComposedComponent = ({compose}) => {
composer = composer || composers[Component.name]
return (
<Component
{...(composer ? composer(compose.state, compose.actions) : compose)}
/>
)
}
return ComposedComponent
}
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