Skip to content

Instantly share code, notes, and snippets.

@spoike
spoike / reflux.js
Created June 29, 2014 22:23
A simpler implementation of React.JS's Flux
var EventEmitter = require('events').EventEmitter,
_ = require('lodash');
/**
* Creates an action functor object
*/
exports.createAction = function() {
var action = new EventEmitter(),
eventLabel = "action",
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@btm1
btm1 / set-if
Created October 2, 2013 23:51
set-if will conditionally show or hide elements in the DOM once and will not apply a $watch listener. An additional attribute (wait-for) can be applied to the element to wait for data to be populated before evaluating the if statement i.e. <div set-if="should.behere" wait-for="should"></div>
angular.module('setIf',[]).directive('setIf',function () {
return {
transclude: 'element',
priority: 1000,
terminal: true,
restrict: 'A',
compile: function (element, attr, linker) {
return function (scope, iterStartElement, attr) {
if(attr.waitFor) {
var wait = scope.$watch(attr.waitFor,function(nv,ov){