@cerebral/vue

Vue.js view for Cerebral.

Install 

npm install @cerebral/vue vue

Container 

import Vue from 'vue/dist/vue'
import { Controller } from 'cerebral'
import { Container, connect } from '@cerebral/vue'

const controller = Controller({
  state: {
    foo: 'bar'
  },
  signals: {
    clicked: []
  }
})

var app = new Vue({
  el: '#app',
  components: {
    container: Container(controller)
  }
})

Note! The HTML of the root element must use the container:

<div id="app">
  <container>
    <my-component></my-component>
  </container>
</div>

connect 

MyComponent.js

import { connect } from '@cerebral/vue'
import { state, signal } from 'cerebral/tags'

export default connect(
  {
    foo: state`foo`,
    click: signal`clicked`
  },
  {
    template: '<div v-on:click="click()">{{foo}}</div>'
  }
)

main.js

import Vue from 'vue/dist/vue'
import { Controller } from 'cerebral'
import { Container, connect } from '@cerebral/vue'
import MyComponent from './MyComponent'

const controller = Controller({
  state: {
    foo: 'bar'
  },
  signals: {
    clicked: []
  }
})

var app = new Vue({
  el: '#app',
  components: {
    container: Container(controller),
    'my-component': MyComponent
  }
})