This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Counter = () => { | |
const [count, setCount] = React.useState(0); | |
React.useEffect(() => { | |
const handleScroll = () => { | |
setCount(countState => countState + 1); | |
}; | |
document.addEventListener(“scroll”, handleScroll); | |
// Clean up | |
return () => document.removeEventListener(“scroll”, handleScroll); | |
}, []); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = injector.set ()-> | |
# Takes all input streams that have the following format | |
# inputName[file] that contains a stream and inputName[data] that contains metaData | |
# and combines them together and adds it to the req.body.inputName for easy access | |
fileParser = (req, res, next)-> | |
if req.is('multipart/form-data') and req._fileparser? | |
do async => | |
streamNames = _.map(req._fileparser.upstreams, 'fieldName') | |
try | |
### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare const _ | |
export class Store { | |
_reducers: {path: string, reducer: Function, id: number}[] = [] | |
__state__: any | |
_id: number | |
_subscribers = {} | |
constructor(initialState){ | |
this.__state__ = initialState | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare const _ | |
export class EventEmitter { | |
_listeners: {[key: string]: Function[]} = {} | |
_eventQueue: {[key: string]: any[]} = {} | |
on(eventName, listener: Function) { | |
this._listeners[eventName] = this._listeners[eventName] || [] | |
this._listeners[eventName].push(listener) | |
this._callPendingEvents(eventName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Zaggen - 2017 | |
* version: 0.1 | |
* github: https://github.com/Zaggen | |
* Free to use and modify | |
* */ | |
const httpProxy = require('http-proxy') | |
const http = require('http') | |
const proxy = httpProxy.createProxyServer({}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare const _: _.LoDashStatic | |
export function traits(...traitsList) { | |
return function decorator(constructor: any) { | |
const mergedTraits = _.extend.apply(_, traitsList) | |
const {prototype} = constructor | |
const {__proto__} = constructor.prototype | |
const prototypeClone = _.clone(prototype) // We use a clone to avoid getting properties on the proto chain | |
constructor.prototype = _.extend(prototype, mergedTraits, prototypeClone) | |
constructor.prototype.constructor = constructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare const _: _.LoDashStatic | |
import {template} from '../helpers/index' | |
interface BackBoneComponent { | |
el?: string, | |
template?: string | Function, | |
events?: any, | |
subComponents?: any[], | |
[key: string]: any | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IObjectLiteral { | |
[key: string]: any | |
} | |
// @description This type of view takes care of extra initialization | |
// and rendering of the element. It allows you to define components | |
// in a similar fashion of angular 2; You define a subComponents | |
// by adding its class to the subComponents array and add the corresponding | |
// tagName on the template, and it will be replaced at runtime. You can pass | |
// attributes to those subComponents by defining them on the empty tag element | |
export class ComponentView extends Backbone.View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helper = { | |
populateFormData: (formData, populationData)-> | |
@_iterativePush(formData, populationData); | |
return formData | |
_iterativePush: (formData, v, k = '')-> | |
if _.isObject(v) | |
_.each v, (v, innerK)=> | |
@_iterativePush(formData, v, "#{k}[#{innerK}]") | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App.Models.Base extends Backbone.Model | |
schema: {} | |
set: (attributes, options)-> | |
if _.isString(attributes) | |
[key, val] = [attributes, options] | |
(attributes = {})[key] = val | |
options = null | |
super(@filter(attributes), options) |
NewerOlder