Skip to content

Instantly share code, notes, and snippets.

View Oikio's full-sized avatar

Oikio Oikio

  • Germany, Munich
View GitHub Profile
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
'use strict';
var m = require('mithril');
var t = require('client/utils/translate');
var vagueTime = require('vague-time');
var l16n = require('client/utils/l16n');
function assignValue(obj, objAttr) {
return function (event) {
@barneycarroll
barneycarroll / mithril-on.js
Created May 6, 2016 10:40
Bind custom events on Mithril elements via config function
export default ( keyOrHash, handler ) =>
function config( el, init, ctxt ){
if( init ) return
const hash = handler ? {
[ keyOrHash ] : handler
} : keyOrHash
for( let key in hash )
if( hash.hasOwnProperty( key ) )