Skip to content

Instantly share code, notes, and snippets.

View danielyogel's full-sized avatar

Daniel Yogel danielyogel

  • IM Creator
  • Tel Aviv
View GitHub Profile
@danielyogel
danielyogel / gulpfile.js
Created July 28, 2014 22:18
gulp config
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require("gulp-rename"),
ngAnnotate = require('gulp-ng-annotate'),
sourcemaps = require('gulp-sourcemaps'),
livereload = require('gulp-livereload'),
templateCache = require('gulp-angular-templatecache'),
compass = require('gulp-compass');
gulp.task('watch-prod', ['templates', 'js-prod', 'sass'], function () {
livereload.listen();
gulp.watch('js/**/*.html', ['templates']);
gulp.watch(['js/**/*.js', 'dist/templates.js'], ['js-prod']);
gulp.watch('**/*.scss', ['sass']);
gulp.watch(['dist/**']).on('change', livereload.changed);
});
/*
* FILES
* */
var unitTestFiles = 'dist/**/**.spec.js',
integrationTestFiles = 'dist/**/**.integSpec.js',
distJsFiles = 'dist/**/*.js',
es6files = 'es6/**/*.js';
/*
* Directories
@danielyogel
danielyogel / gist:a9d1756aae24549ebf58
Created September 16, 2014 19:43
promise streams
function traceurPromise() {
console.log('STARTING TRACEUR ');
return new Promise(function (resolve, reject) {
gulp.src(es6files)
.pipe(traceur(traceurOpts))
.pipe(gulp.dest(distDirectory))
.on('end', function () {
console.log('ENDED TRACEUR ');
resolve();
});
@danielyogel
danielyogel / loop
Created October 23, 2014 17:35
promises generators for in loop.
co(
for (var i in list) {
try {
yield promiseMeSomething(list[i]);
} catch (err) {
console.log(err.message);
}
})()
@danielyogel
danielyogel / gist:100cd98b01821ba16c88
Created February 24, 2015 17:56
forceUpdate for hipsters :-)
var ModelEventsMixin = {
shouldComponentUpdate: () => false,
componentWillMount: function () {
var self = this;
this.modelsToListen.forEach(function (model_name) {
eventEmitter.addListener(model_name + '_model_update', self.listener); // PROBLEM if I hange listener to forceUpdate.
});
},
componentWillUnmount: function () {
@danielyogel
danielyogel / Redux-Observable Redux-Saga
Last active December 10, 2016 22:40
How whould you translate the following "epic" or "saga" to MobX? Just interested...
//Epic
export default function searchUsers(action$) {
return action$.ofType(ActionTypes.SEARCHED_USERS)
.map(action => action.payload.query)
.filter(q => !!q)
.switchMap(q =>
Observable.timer(800) // debounce
.takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS))
.mergeMap(() => Observable.merge(