fix(core): update
This commit is contained in:
parent
e8057c0c95
commit
b06ceaa9bf
25288
package-lock.json
generated
25288
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -5,6 +5,7 @@
|
||||
"description": "smart wrapper for rxjs",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@ -12,18 +13,18 @@
|
||||
"build": "(tsbuild --web && tsbundle npm)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.29",
|
||||
"@gitzone/tsbundle": "^1.0.89",
|
||||
"@gitzone/tsrun": "^1.2.18",
|
||||
"@gitzone/tstest": "^1.0.60",
|
||||
"@pushrocks/tapbundle": "^4.0.0",
|
||||
"@types/node": "^17.0.10",
|
||||
"@gitzone/tsbuild": "^2.1.65",
|
||||
"@gitzone/tsbundle": "^2.0.7",
|
||||
"@gitzone/tsrun": "^1.2.37",
|
||||
"@gitzone/tstest": "^1.0.73",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.4",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"rxjs": "^7.5.2"
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartrx from '../ts/index';
|
||||
import * as smartrx from '../ts/index.js';
|
||||
|
||||
tap.test('should create a valid instance of observableinstake', async () => {
|
||||
const testObservableIntake = new smartrx.ObservableIntake();
|
@ -5,7 +5,7 @@ import * as rx from 'rxjs';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
// import the module
|
||||
import * as smartrx from '../ts/index';
|
||||
import * as smartrx from '../ts/index.js';
|
||||
|
||||
let testObservablemap: smartrx.Observablemap;
|
||||
let testObservable1: rx.Observable<any>;
|
||||
@ -21,12 +21,12 @@ tap.test('should create an instance', async () => {
|
||||
tap.test('should accept a new emitter', async () => {
|
||||
let done = smartpromise.defer();
|
||||
testEmitter = new events.EventEmitter();
|
||||
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
||||
testObservable1 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||
testObservable1.subscribe((x) => {
|
||||
done.resolve();
|
||||
});
|
||||
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
||||
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2');
|
||||
testObservable2 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||
testObservable3 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event2');
|
||||
expect(testObservable1 === testObservable2).toBeTrue();
|
||||
expect(testObservable1 === testObservable3).toBeFalse();
|
||||
testEmitter.emit('event1');
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartrx',
|
||||
version: '2.0.26',
|
||||
description: 'smart wrapper for rxjs'
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './smartrx.plugins';
|
||||
export * from './smartrx.classes.observablemap';
|
||||
export * from './smartrx.classes.observableintake';
|
||||
import * as rxjs from './smartrx.plugins.rxjs';
|
||||
import * as plugins from './smartrx.plugins.js';
|
||||
export * from './smartrx.classes.observablemap.js';
|
||||
export * from './smartrx.classes.observableintake.js';
|
||||
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||
export {
|
||||
rxjs
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartrx.plugins';
|
||||
import * as plugins from './smartrx.plugins.js';
|
||||
|
||||
import * as rxjs from './smartrx.plugins.rxjs';
|
||||
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||
|
||||
/**
|
||||
* ObservableIntake
|
||||
@ -22,7 +22,7 @@ export class ObservableIntake<T> {
|
||||
private payloadBuffer: any[] = [];
|
||||
|
||||
constructor() {
|
||||
this.observable = rxjs.Observable.create((observerArg: rxjs.Observer<any>) => {
|
||||
this.observable = new rxjs.Observable((observerArg: rxjs.Observer<any>) => {
|
||||
this.observableFunctions.next = (...args: any) => {
|
||||
return observerArg.next(args);
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as plugins from './smartrx.plugins';
|
||||
import * as rxjs from './smartrx.plugins.rxjs';
|
||||
import * as plugins from './smartrx.plugins.js';
|
||||
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||
|
||||
export interface IEventEmitter<T = any> {
|
||||
on: (eventNameArg: string, eventHandlerArg: (eventPayload: T) => any) => void;
|
||||
@ -8,9 +8,9 @@ export interface IEventEmitter<T = any> {
|
||||
/**
|
||||
* bundles an observable with an emitter
|
||||
*/
|
||||
export interface IObservableEmitterBundle {
|
||||
observable: rxjs.Observable<any>;
|
||||
emitter: IEventEmitter<unknown>;
|
||||
export interface IObservableEventBundle<T> {
|
||||
subject: rxjs.Subject<any>;
|
||||
eventRef: T;
|
||||
event: string;
|
||||
}
|
||||
|
||||
@ -18,26 +18,56 @@ export interface IObservableEmitterBundle {
|
||||
* manages observables by making sure that only one observable is regsitered per event
|
||||
*/
|
||||
export class Observablemap {
|
||||
public observableEmitterBundleArray = new Array<IObservableEmitterBundle>();
|
||||
public observableEventEmitterBundleArray = new Array<
|
||||
IObservableEventBundle<IEventEmitter<unknown>>
|
||||
>();
|
||||
public observableEventTargetBundleArray = new Array<IObservableEventBundle<EventTarget>>();
|
||||
|
||||
/**
|
||||
* creates a new observable if not yet registered for the same event.
|
||||
* creates a hot subject if not yet registered for the event.
|
||||
* In case event has been registered before the same observable is returned.
|
||||
*/
|
||||
public getObservableForEmitterEvent<T>(emitterArg: IEventEmitter<T>, eventArg: string) {
|
||||
const existingBundle = this.observableEmitterBundleArray.find((bundleArg) => {
|
||||
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg;
|
||||
public getSubjectForEmitterEvent<T>(
|
||||
emitterArg: IEventEmitter<T>,
|
||||
eventArg: string
|
||||
): rxjs.Subject<T> {
|
||||
const existingBundle = this.observableEventEmitterBundleArray.find((bundleArg) => {
|
||||
return bundleArg.eventRef === emitterArg && bundleArg.event === eventArg;
|
||||
});
|
||||
if (existingBundle) {
|
||||
return existingBundle.observable;
|
||||
return existingBundle.subject;
|
||||
} else {
|
||||
const emitterObservable = rxjs.fromEvent<T>(emitterArg as any, eventArg);
|
||||
this.observableEmitterBundleArray.push({
|
||||
observable: emitterObservable,
|
||||
emitter: emitterArg,
|
||||
const emitterSubject = new rxjs.Subject();
|
||||
emitterObservable.subscribe(emitterSubject);
|
||||
const newBundle: IObservableEventBundle<IEventEmitter> = {
|
||||
subject: emitterSubject,
|
||||
eventRef: emitterArg,
|
||||
event: eventArg,
|
||||
});
|
||||
return emitterObservable;
|
||||
};
|
||||
this.observableEventEmitterBundleArray.push(newBundle);
|
||||
return newBundle.subject;
|
||||
}
|
||||
}
|
||||
|
||||
public getSubjectForEventTarget<T>(
|
||||
eventTargetArg: EventTarget,
|
||||
eventNameArg: string
|
||||
): rxjs.Subject<T> {
|
||||
const existingBundle = this.observableEventTargetBundleArray.find((bundleArg) => {
|
||||
return bundleArg.eventRef === eventTargetArg && bundleArg.event === eventNameArg;
|
||||
});
|
||||
if (existingBundle) {
|
||||
return existingBundle.subject;
|
||||
} else {
|
||||
const emitterSubject = new rxjs.Subject();
|
||||
const newBundle: IObservableEventBundle<EventTarget> = {
|
||||
subject: emitterSubject,
|
||||
eventRef: eventTargetArg,
|
||||
event: eventNameArg,
|
||||
};
|
||||
this.observableEventTargetBundleArray.push(newBundle);
|
||||
return newBundle.subject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// this file is intended to keep the bundle size down
|
||||
|
||||
export { Observable, Subject, fromEvent, ReplaySubject, Subscription, Observer } from 'rxjs';
|
||||
export { Observable, Subject, fromEvent, ReplaySubject, Subscription } from 'rxjs';
|
||||
|
||||
export type { Observer } from 'rxjs';
|
||||
|
||||
import { startWith, takeUntil, map, debounce, debounceTime } from 'rxjs/operators';
|
||||
|
||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Loading…
Reference in New Issue
Block a user