View moment.pipe.ts
This file contains 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
import {Pipe, PipeTransform} from '@angular/core'; | |
import * as moment from 'moment'; | |
@Pipe({ | |
name: 'moment' | |
}) | |
export class MomentPipe implements PipeTransform { | |
transform(date, format) { | |
return moment(date).format(format); | |
} |
View angular-cli-build.js
This file contains 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
/* global require, module */ | |
var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); | |
const vendorNpmFiles = [ | |
'systemjs/dist/system-polyfills.js', | |
'systemjs/dist/system.src.js', | |
'zone.js/dist/**/*.+(js|js.map)', | |
'es6-shim/es6-shim.js', | |
'reflect-metadata/**/*.+(js|js.map)', |
View worker.js
This file contains 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
function $worker() { | |
var workers = []; | |
// PUBLIC_API | |
return { | |
create: create, | |
runAll: runAll, | |
terminateAll: terminateAll, | |
list: list | |
} |
View inline-worker-in-action.js
This file contains 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
var myWorker = createWorker(function (e) { | |
self.postMessage(e.data.toUpperCase()); | |
}); | |
myWorker.onMessage = function (e) { | |
console.log(e.data); // HELLO FROM AN INLINE WORKER! | |
} | |
myWorker.postMessage('hello from an inline worker!') |
View normal-web-worker.js
This file contains 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
// New workers is created for a link to an external js file | |
var myWorker = new Worker('web-worker.js'); | |
// function to fire when a message is sent from the worker. | |
myWorker.onmessage = function (e) { | |
console.log(e.data); // HELLO WORLD | |
} | |
// send a message to the worker | |
myWorker.postMessage('hello world'); |
View app-state.ts
This file contains 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
import { Injectable } from '@angular/core'; | |
import { Subject } from 'rxjs/Subject'; | |
@Injectable() | |
export class AppStateService { | |
changes: Subject<any> = new Subject(); | |
private state: any = {}; | |
private history: any[] = []; | |
private historyPos: number = 0; |
View rxjs-worker-map.example.js
This file contains 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
// https://github.com/deebloo/rxjs-worker | |
var observable = Observable.of([0, 1, 2, 3, 4]); | |
observable | |
.map(function (data) { | |
return data.concat([5, 6, 7, 8, 9]); | |
}) | |
.workerMap(function (data) { | |
return data.concat([10,11,12,13,14]);; | |
}) |
View composable-redux-actions.ts
This file contains 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
import { createStore } from 'redux'; | |
const add1 = () => { | |
type: 'ADD1', | |
payload: state => [{}, ...state] | |
} | |
const add2 = () => { | |
type: 'ADD2', | |
payload: state => add1().payload(add1().payload(state)) |
View compose.ts
This file contains 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
// Our compose function that can be used as a decorator | |
// Decorators are just functions | |
const Compose = (mixins: any[]) => { | |
const protos = mixins.map(mixin => mixin.prototype) | |
const targetFunc = target => { | |
Object.assign(target.prototype, ...protos) | |
} | |
targetFunc.create = (base: any) =>{ |
View 0-sweet-modals.component.ts
This file contains 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
import { Component, Input } from '@angular/core'; | |
@Component({ | |
selector: 'sweet-modal', | |
styleUrls: ['sweet-modal.component.css'] | |
templateUrl: 'sweet-modal.component.html' | |
}) | |
export class LsModalComponent { | |
@Input() width: string = '400px'; |
OlderNewer