Skip to content

Instantly share code, notes, and snippets.

View mkozhukharenko's full-sized avatar

Nikolay mkozhukharenko

View GitHub Profile
@mkozhukharenko
mkozhukharenko / event-emitter-improved.js
Created June 30, 2016 20:14
Simple Event Emitter Improved
// make EE singelton, add .off method
let instance = null;
class EventEmitter {
constructor() {
// ensure we have only one instance (singelton pattern)
if (!instance) {
instance = this;
}
@mkozhukharenko
mkozhukharenko / event-emitter.js
Last active June 30, 2016 20:13
Simple Event Emitter
// Simple Event emitter realization
class EventEmitter {
constructor() {
// store for handlers
this.events = {};
}
// subscribe
on(name, fn) {
this.events[name] = this.events[name] || [];
@mkozhukharenko
mkozhukharenko / koa-passport-auth.js
Created June 9, 2016 07:22 — forked from moustacheful/koa-passport-auth.js
Koa passport.authenticate wrapper
// koa-passport-authenticate.js
'use strict'
const _ = require('lodash')
const passport = require('koa-passport')
'use strict'
// Middleware wrapper for koa passport to have proper error handling on authenticate.
@mkozhukharenko
mkozhukharenko / NotficationActionTypes.js
Created February 14, 2016 19:33 — forked from jerairrest/NotficationActionTypes.js
React-toastr Redux Implementation
export const RECEIVE_MESSAGE = 'RECEIVE_MESSAGE';