Revisions
-
micdenny revised this gist
Jan 24, 2018 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export class MessageService { this._message$.next({ 'channel': channel, 'content': messageInstance }); } public of<T>(messageClass: { new (...args: any[]): T }): Observable<T> { // Flux: 'subscribe' = 'on' const channel = messageClass; return this._message$.filter((message) => { return message.channel === channel }).map((message) => { return message.content; }); } 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ import * as message from './MessageServiceClasses'; // assume MessageService is injected & some callback handlers defined to pass in this.MessageService.of(message.ProcedureUpdateNameOnClientRequestMessage) .subscribe(this.updateNameOnClientRequestHandle.bind(this), this._genericErrorHandler.bind(this)) -
KeithGillette revised this gist
Nov 22, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ import * as angular from 'angular'; import { Observable, Subject, Subscription } from '@reactivex/rxjs'; export interface Message { channel: Function; -
KeithGillette revised this gist
Oct 30, 2016 . No changes.There are no files selected for viewing
-
KeithGillette revised this gist
Oct 30, 2016 . No changes.There are no files selected for viewing
-
KeithGillette created this gist
Oct 30, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import * as angular from 'angular'; import { Observable, Subject, Subscription } from '@reactivex/rxjs'; import * as domain from '../models'; export interface Message { channel: Function; content: any; } /** * @description AngularJS service singleton implementing simple publish/subscribe message bus to provide decoupled communication of commands & events */ export class MessageService { private _message$: Subject<Message> constructor() { this._message$ = new Subject<Message>(); } public publish<T>(messageInstance: T): void { // Flux: 'publish' = 'dispatch', 'channel' = 'action' const channel: Function = messageInstance.constructor; this._message$.next({ 'channel': channel, 'content': messageInstance }); } public subscribe<T>(messageClass: { new (...args: any[]): T }): Observable<T> { // Flux: 'subscribe' = 'on' const channel = messageClass; return this._message$.filter((message) => { return message.channel === channel }).map((message) => { return message.content; }); } } angular.module('TaskTrainApp') .service('MessageService', MessageService); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // Just some sample message classes /** * @description encapsulation class for messages sent to the MessageService message bus to provide channel type and TypeScript typing */ export class UserNotificationMessage { constructor( public message: string, public notificationType?: NotificationType, public options?: any, public notifier?: any ) { } } export type NotificationType = 'success' | 'info' | 'warning' | 'danger' | 'error'; /** * @description base class for all DomainModelService UPDATE operations */ abstract class DomainModelUpdateRequestMessage { constructor( public id: string, public domainModelObject: domain.IDomainModel, public newValue?: any, public oldValue?: any, ) { } } /** * @description encapsulation class for messages sent to the MessageService message bus to provide TypeScript typing */ export class ProcedureUpdateNameOnClientRequestMessage extends DomainModelUpdateRequestMessage { public domainModelObject: domain.IProcedure; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ import * as message from './MessageServiceClasses'; // assume MessageService is injected this.MessageService.publish(new message.ProcedureUpdateNameOnClientRequestMessage(this.id, this, newValue, this._name)); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ import * as message from './MessageServiceClasses'; // assume MessageService is injected & some callback handlers defined to pass in this.MessageService.subscribe(message.ProcedureUpdateNameOnClientRequestMessage) .subscribe(this.updateNameOnClientRequestHandle.bind(this), this._genericErrorHandler.bind(this))