How to use the riot.mixin 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 Acesmndr / chrome-extension-boilerplate-riot / src / popup / components / __tests__ / pageone.spec.js View on Github external
beforeAll( () => {
        expect(mockFn.mock.calls.length).toBe(0);
        riot.mixin('messageMixin', messageMixin);
        // create mounting point 
        const elem = document.createElement('div');
        elem.className = "main-body";
        document.body.appendChild(elem)
        riot.mount(elem, {}, pageone);
    });
github Frost-Dev / Frost-Web / src / client / mainEntry.js View on Github external
route('users/*', (screenName) =>
		changePage('user', { screenName }));

	route('posts/*', (postId) =>
		changePage('post', { postId }));

	route('*', () =>
		changePage('error', { message: 'page not found' }));

	loadTags();

	await waitRecaptcha(mixin.siteKey);

	// mount riot tags
	riot.mixin(mixin);
	riot.mount('*');

	route.start(true);

	// NOTE: move to error page by content of error metaData only when initialization
	if (mixin.error != null) {
		changePage('error');
	}
	// NOTE: move to target page by content of page metadata only when initialization
	else if (mixin.page != null) {
		changePage(mixin.page);
	}

})().catch(err => {
	console.log('何かがおかしいよ');
github denizdogan / chrome-extension-temporary-email / src / options / script.js View on Github external
let query = {}
      query[key] = value
      store.set(query, cb)
    }

    // get
    this.get = function (key, cb) {
      store.get(key, function (response) {
        cb(response[key])
      })
    }
  }
}

// make all components storage mixins
riot.mixin(StorageMixin)

import './components.tag'

// initialize the view model
let sections = [{
  title: 'General settings',
  icon: 'cog',
  options: [{
    id: 'open-in-background',
    description: 'Open email tab in background',
    value: true
  }]
}]

import providers from '../js/providers'
github cam-inc / riotx / lib / index.js View on Github external
var riotxChange = function (store, evtName, handler) {
    var args = [], len = arguments.length - 3;
    while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ];

    this._riotx_change_handlers.push({
      store: store,
      evtName: evtName,
      handler: handler
    });
    args.unshift(handler);
    args.unshift(evtName);
    store.change.apply(store, args);
  };

  // register a mixin globally.
  riot.mixin({
    // intendedly use `function`.
    // switch the context of `this` from `riotx` to `riot tag instance`.
    init: function () {
      var this$1 = this;

      // the context of `this` will be equal to riot tag instant.
      this.on('unmount', function () {
        this$1.off('*');
        forEach_1(this$1._riotx_change_handlers, function (obj) {
          obj.store.off(obj.evtName, obj.handler);
        });
        delete this$1.riotx;
        delete this$1._riotx_change_handlers;
        delete this$1[settings.changeBindName];
      });
github cam-inc / viron / s / samplerouter / router.js View on Github external
* function to stop listening for the changes.
     * to stop, just execute this function.
     * @private
     * @type {Function|null}
     */
    this._unlistener = null;

    /**
     * function to unblock the navigation.
     * to unblock, just execute this function.
     * @type {Function|null}
     */
    this._unblocker = null;

    // make children act as page.
    riot.mixin({
      init: function () {
        const isPage = (this.parent && this.parent.isRoute);
        if (!isPage) {
          return;
        }
        this.routeInfo = this.parent.routeInfo;
      }
    });
  }
github GianlucaGuarini / riot-app-example / shared / components / mixins.js View on Github external
import { mixin } from 'riot'

// add special animation features to the current tag instance
mixin('animation-features', {
  features: { Velocity },
  defaultTransitions: {
    in: 'transition.slideUpIn',
    out: 'transition.slideUpOut'
  },
  moveIn: function (el) {
    return Velocity(el, this.defaultTransitions.in)
  },
  moveOut: function (el) {
    return Velocity(el, this.defaultTransitions.out)
  }
})
github andrewdelprete / boilerplates / riotjs-gulp-browserify-es6-boilerplate / src / scripts / app.js View on Github external
function handler(collection, id, action) {

    if (!Riot.mixin('peoplelistObservable')) {
        Riot.mixin('peoplelistObservable', new PeoplelistObservable());
    }

    if (currentPage) {
        currentPage.unmount(true)
    }

    var fn = routes[collection || 'home'];
    return fn ? fn(id, action) : console.error('no route found : ', collection, id, action);
}
github Frost-Dev / Frost-Web / src / client / index.js View on Github external
method: 'get', endpoint: `/users/${userId}`,
							headers: {'x-api-version': 1.0},
						}
					});
				});
			});

			await readyAsync();
		}
	}
	catch (err) {
		console.log('何かがおかしいよ');
		console.dir(err);
	}

	riot.mixin(mixinGlobal);
	riot.mount('*');
})();
github andrewdelprete / boilerplates / riotjs-gulp-browserify-es6-boilerplate / src / scripts / app.js View on Github external
function handler(collection, id, action) {

    if (!Riot.mixin('peoplelistObservable')) {
        Riot.mixin('peoplelistObservable', new PeoplelistObservable());
    }

    if (currentPage) {
        currentPage.unmount(true)
    }

    var fn = routes[collection || 'home'];
    return fn ? fn(id, action) : console.error('no route found : ', collection, id, action);
}
github gabrielmoreira / riot-router / examples / redux / src / mixins / store.js View on Github external
},

	trackSelector(selector, target) {
		this.onSelectorUpdate(selector, function(state) {
			_.set(this, target, state);
			this.update();
		}.bind(this));
		_.set(this, target, selector(store.getState()));
	},

	storeStateChanged(previous, current) {
		return previous !== current;
	}
}

riot.mixin('store', StoreMixin);