remove rxjs and move Observablemap to smartrx
This commit is contained in:
parent
29d6f2d7e0
commit
3c229e8e26
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
export * from './lik.looptracker';
|
||||
export * from './lik.objectmap';
|
||||
export * from './lik.observablemap';
|
||||
export * from './lik.stringmap';
|
||||
export * from './lik.limitedarray';
|
||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// import modules
|
||||
__export(require("./lik.looptracker"));
|
||||
__export(require("./lik.objectmap"));
|
||||
__export(require("./lik.observablemap"));
|
||||
__export(require("./lik.stringmap"));
|
||||
__export(require("./lik.limitedarray"));
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLGlCQUFpQjtBQUVqQix1Q0FBaUM7QUFDakMscUNBQStCO0FBQy9CLHlDQUFtQztBQUNuQyxxQ0FBK0I7QUFDL0Isd0NBQWtDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLGlCQUFpQjtBQUVqQix1Q0FBaUM7QUFDakMscUNBQStCO0FBQy9CLHFDQUErQjtBQUMvQix3Q0FBa0MifQ==
|
23
dist/lik.observablemap.d.ts
vendored
23
dist/lik.observablemap.d.ts
vendored
@ -1,23 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import * as plugins from './lik.plugins';
|
||||
import { Objectmap } from './lik.objectmap';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
/**
|
||||
* bundles an observable with an emitter
|
||||
*/
|
||||
export interface ObservableEmitterBundle {
|
||||
observable: plugins.rx.Observable<any>;
|
||||
emitter: plugins.events.EventEmitter;
|
||||
event: string;
|
||||
}
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
export declare class Observablemap {
|
||||
ObservableEmitterBundleObjectmap: Objectmap<ObservableEmitterBundle>;
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent(emitterArg: plugins.events.EventEmitter, eventArg: string): Observable<any>;
|
||||
}
|
35
dist/lik.observablemap.js
vendored
35
dist/lik.observablemap.js
vendored
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = require("./lik.plugins");
|
||||
const lik_objectmap_1 = require("./lik.objectmap");
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
class Observablemap {
|
||||
constructor() {
|
||||
this.ObservableEmitterBundleObjectmap = new lik_objectmap_1.Objectmap();
|
||||
}
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent(emitterArg, eventArg) {
|
||||
let existingBundle = this.ObservableEmitterBundleObjectmap.find((bundleArg) => {
|
||||
return (bundleArg.emitter === emitterArg && bundleArg.event === eventArg);
|
||||
});
|
||||
if (existingBundle) {
|
||||
return existingBundle.observable;
|
||||
}
|
||||
else {
|
||||
let emitterObservable = plugins.rx.Observable.fromEvent(emitterArg, eventArg);
|
||||
this.ObservableEmitterBundleObjectmap.add({
|
||||
observable: emitterObservable,
|
||||
emitter: emitterArg,
|
||||
event: eventArg
|
||||
});
|
||||
return emitterObservable;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Observablemap = Observablemap;
|
||||
//# sourceMappingURL=data:application/json;base64,e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ixDQUFBO1FBQzFCLENBQUM7SUFDSCxDQUFDO0NBQ0Y7QUF2QkQsc0NBdUJDIn0=
|
3
dist/lik.plugins.d.ts
vendored
3
dist/lik.plugins.d.ts
vendored
@ -3,5 +3,4 @@ import * as smartq from 'smartq';
|
||||
import * as events from 'events';
|
||||
import * as lodash from 'lodash';
|
||||
import * as minimatch from 'minimatch';
|
||||
import * as rx from 'rxjs/Rx';
|
||||
export { smartq, events, lodash, minimatch, rx };
|
||||
export { smartq, events, lodash, minimatch };
|
||||
|
4
dist/lik.plugins.js
vendored
4
dist/lik.plugins.js
vendored
@ -9,6 +9,4 @@ const lodash = require("lodash");
|
||||
exports.lodash = lodash;
|
||||
const minimatch = require("minimatch");
|
||||
exports.minimatch = minimatch;
|
||||
const rx = require("rxjs/Rx");
|
||||
exports.rx = rx;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFPOUIsd0JBQU07QUFOUixpQ0FBZ0M7QUFPOUIsd0JBQU07QUFOUixpQ0FBZ0M7QUFPOUIsd0JBQU07QUFOUix1Q0FBc0M7QUFPcEMsOEJBQVM7QUFOWCw4QkFBNkI7QUFPM0IsZ0JBQUUifQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFNOUIsd0JBQU07QUFMUixpQ0FBZ0M7QUFNOUIsd0JBQU07QUFMUixpQ0FBZ0M7QUFNOUIsd0JBQU07QUFMUix1Q0FBc0M7QUFNcEMsOEJBQVMifQ==
|
@ -25,7 +25,6 @@
|
||||
"@types/minimatch": "3.x.x",
|
||||
"lodash": "^4.17.4",
|
||||
"minimatch": "^3.0.4",
|
||||
"rxjs": "^5.4.3",
|
||||
"smartq": "^1.1.6",
|
||||
"typings-global": "^1.0.20"
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// import test framework
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as events from 'events'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
// import the module
|
||||
|
@ -1,7 +1,6 @@
|
||||
// import test framework
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as events from 'events'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
// import the module
|
||||
|
@ -1,38 +0,0 @@
|
||||
// import test framework
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as events from 'events'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
// import the module
|
||||
import * as lik from '../ts/index'
|
||||
|
||||
let testObservablemap: lik.Observablemap
|
||||
let testObservable1: rx.Observable<any>
|
||||
let testObservable2: rx.Observable<any>
|
||||
let testObservable3: rx.Observable<any>
|
||||
let testEmitter: events.EventEmitter
|
||||
|
||||
tap.test('should create an instance', async () => {
|
||||
testObservablemap = new lik.Observablemap()
|
||||
expect(testObservablemap).be.instanceof(lik.Observablemap)
|
||||
})
|
||||
|
||||
tap.test('should accept a new emitter', async () => {
|
||||
let done = smartq.defer()
|
||||
testEmitter = new events.EventEmitter()
|
||||
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1')
|
||||
testObservable1.subscribe(x => {
|
||||
done.resolve()
|
||||
})
|
||||
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1')
|
||||
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2')
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObservable1 === testObservable2).be.true
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
expect(testObservable1 === testObservable3).be.false
|
||||
testEmitter.emit('event1')
|
||||
await done.promise
|
||||
})
|
||||
|
||||
tap.start()
|
@ -1,7 +1,6 @@
|
||||
// import test framework
|
||||
import { expect, tap } from 'tapbundle'
|
||||
import * as events from 'events'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
import * as smartq from 'smartq'
|
||||
|
||||
// import the module
|
||||
|
@ -4,6 +4,5 @@ import * as plugins from './lik.plugins'
|
||||
|
||||
export * from './lik.looptracker'
|
||||
export * from './lik.objectmap'
|
||||
export * from './lik.observablemap'
|
||||
export * from './lik.stringmap'
|
||||
export * from './lik.limitedarray'
|
||||
|
@ -1,41 +0,0 @@
|
||||
import * as plugins from './lik.plugins'
|
||||
import { Objectmap } from './lik.objectmap'
|
||||
import { Stringmap } from './lik.stringmap'
|
||||
import { Observable } from 'rxjs/Rx'
|
||||
|
||||
/**
|
||||
* bundles an observable with an emitter
|
||||
*/
|
||||
export interface ObservableEmitterBundle {
|
||||
observable: plugins.rx.Observable<any>
|
||||
emitter: plugins.events.EventEmitter
|
||||
event: string
|
||||
}
|
||||
|
||||
/**
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
export class Observablemap {
|
||||
ObservableEmitterBundleObjectmap = new Objectmap<ObservableEmitterBundle>()
|
||||
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
getObservableForEmitterEvent (emitterArg: plugins.events.EventEmitter, eventArg: string) {
|
||||
let existingBundle = this.ObservableEmitterBundleObjectmap.find((bundleArg) => {
|
||||
return (bundleArg.emitter === emitterArg && bundleArg.event === eventArg)
|
||||
})
|
||||
if (existingBundle) {
|
||||
return existingBundle.observable
|
||||
} else {
|
||||
let emitterObservable = plugins.rx.Observable.fromEvent(emitterArg, eventArg)
|
||||
this.ObservableEmitterBundleObjectmap.add({
|
||||
observable: emitterObservable,
|
||||
emitter: emitterArg,
|
||||
event: eventArg
|
||||
})
|
||||
return emitterObservable
|
||||
}
|
||||
}
|
||||
}
|
@ -3,12 +3,10 @@ import * as smartq from 'smartq'
|
||||
import * as events from 'events'
|
||||
import * as lodash from 'lodash'
|
||||
import * as minimatch from 'minimatch'
|
||||
import * as rx from 'rxjs/Rx'
|
||||
|
||||
export {
|
||||
smartq,
|
||||
events,
|
||||
lodash,
|
||||
minimatch,
|
||||
rx
|
||||
minimatch
|
||||
}
|
||||
|
10
yarn.lock
10
yarn.lock
@ -302,12 +302,6 @@ resolve@^1.1.6:
|
||||
dependencies:
|
||||
path-parse "^1.0.5"
|
||||
|
||||
rxjs@^5.4.3:
|
||||
version "5.4.3"
|
||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.3.tgz#0758cddee6033d68e0fd53676f0f3596ce3d483f"
|
||||
dependencies:
|
||||
symbol-observable "^1.0.1"
|
||||
|
||||
semver@^5.3.0:
|
||||
version "5.4.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
||||
@ -356,10 +350,6 @@ smartshell@^1.0.6:
|
||||
typings-global "^1.0.20"
|
||||
which "^1.3.0"
|
||||
|
||||
symbol-observable@^1.0.1:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
|
||||
|
||||
tapbundle@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.1.tgz#ec4172c0e82a77b1f6133fef2606311ede28a62d"
|
||||
|
Loading…
Reference in New Issue
Block a user