How to use the riot.observable function in riot

To help you get started, we’ve selected a few riot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Frost-Dev / Frost-Web / src / assets / scripts / main.js View on Github external
import riot from 'riot';

// components
import '../tags/frost-login-form.tag';
import '../tags/frost-signup-form.tag';
import '../tags/frost-logout-button.tag';
import '../tags/frost-create-status-form.tag';
import '../tags/frost-post-status.tag';
import '../tags/frost-public-timeline.tag';
import '../tags/frost-applications.tag';
import '../tags/frost-create-application-form.tag';

const socket = io(); /* headのscriptタグからsocket.ioを読み込んで使用している(妥協) */
const obs = riot.observable();

const mountOption = {obs: obs, socket: socket};

let userId;
const elements = document.getElementsByName('frost-userId');
if(elements.length != 0) {
	userId = elements.item(0).content;
}

socket.once('ready', (readyData) => {
	if (userId != null) {
		mountOption.userId = userId;
		socket.emit('rest', {request: {
			method: 'get', endpoint: `/users/${userId}`,
			headers: {'x-api-version': 1.0},
		}});
github GraphWalker / graphwalker-project / graphwalker-studio / src / main / webapp / scripts / stores / EdgeStore.js View on Github external
function EdgeStore() {
    var self = riot.observable(this);

    // Register store with RiotControl. All subsequent `trigger` and `on` method calls through
    // RiotControl will be passed on to this store.
    RiotControl.addStore(self);

    // DATA STORE
    self.edges = [];

    // Utils
    var _getEdge = Utils.getElement.bind(undefined, self.edges);

    // Event listeners
    var CALLS = Constants.calls;
    var EVENTS = Constants.events;
    var EMIT_CHANGE = EVENTS.EDGE_LIST_CHANGED;
    self.on(CALLS.GET_ALL_EDGES, function(callback) {
github ListnPlay / riot-isomorphic / src / app / stores / store.js View on Github external
constructor() {
        console.log("Store base class constructor");
        this.control = {};
        riot.observable(this.control);
    }
    on() {
github cam-inc / viron / s / riotx / index.js View on Github external
* mutaions.
     * mutaion = a function which mutates the state.
     * all mutation functions take two parameters which are `state` and `obj`.
     * `state` will be TODO.
     * `obj` will be TODO.
     * @type {Object}
     */
    this._mutations = ObjectAssign({}, _store.mutations);

    /**
     * functions to get data from states.
     * @type {Object}
     */
    this._getters = ObjectAssign({}, _store.getters);

    riot.observable(this);
  }
github claudetech / riot-form / lib / form.js View on Github external
constructor(config = {}) {
    assert(config.name, 'A form must have a name')
    riot.observable(this)
    this._config = config
    this._inputs = config.inputs || {}
    this._forms = config.forms || {}
    this.model = config.model || {}
    this.name = config.name
    this._errors = {}
  }
github marcbachmann / limelight / client / configuration / index.js View on Github external
init: function () {
      var self = this
      self.route = {}
      riot.observable(self.route)

      riot.route(function (collection, id, action) {
        var current = [collection]
        if (id) current.push(id)
        if (id && action) current.push(action)
        self.route.collection = collection
        self.route.id = id
        self.route.action = action
        self.path = current.join('/')

        if (self.path === path.replace(':id', id)) {
          self.update({show: true})
          self.route.trigger('show')
        } else {
          self.update({show: false})
          self.route.trigger('hide')
github danigb / music-scale / browser.js View on Github external
function App (state) {
  this.state = state
  this.events = riot.observable({})
  this.scales = require('./scales.js')
  this.render = require('./render.js')
  this.route = require('./router.js')(this)
  this.play = require('./player.js')
}
github danigb / music-scale / app / app.js View on Github external
function App (state) {
  this.state = state
  this.events = riot.observable({})
  this.scales = require('./scales.js')
  this.render = require('./render.js')
  this.route = require('./router.js')(this)
  this.play = require('./player.js')
}
github claudetech / riot-form / lib / inputs / base.js View on Github external
constructor(config = {}) {
    riot.observable(this)
    assert(config.name, 'An input must have a name')
    this.config = config
    this.setValue(config.value || this.defaultValue, {silent: true})
    if (config.formName) {
      this.formName = config.formName
    }
  }
github Frost-Dev / Frost-Web / src / client / helpers / web-socket-events.js View on Github external
return new Promise((resolve, reject) => {
			if (url == null) {
				return reject(new ReferenceError('missing argumets'));
			}

			const ws = new WebSocket2(url, [], { reconnectInterval: 3000 });
			riot.observable(ws);
			ws.addEventListener('error', (errorEvent) => { reject(errorEvent); });
			ws.addEventListener('close', (closeEvent) => { reject(closeEvent); });
			ws.addEventListener('open', () => {
				resolve(ws);
			});
		});
	}