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",
|
"description": "smart wrapper for rxjs",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -12,18 +13,18 @@
|
|||||||
"build": "(tsbuild --web && tsbundle npm)"
|
"build": "(tsbuild --web && tsbundle npm)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.29",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsbundle": "^1.0.89",
|
"@gitzone/tsbundle": "^2.0.7",
|
||||||
"@gitzone/tsrun": "^1.2.18",
|
"@gitzone/tsrun": "^1.2.37",
|
||||||
"@gitzone/tstest": "^1.0.60",
|
"@gitzone/tstest": "^1.0.73",
|
||||||
"@pushrocks/tapbundle": "^4.0.0",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^17.0.10",
|
"@types/node": "^18.6.4",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"rxjs": "^7.5.2"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
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 () => {
|
tap.test('should create a valid instance of observableinstake', async () => {
|
||||||
const testObservableIntake = new smartrx.ObservableIntake();
|
const testObservableIntake = new smartrx.ObservableIntake();
|
@ -5,7 +5,7 @@ import * as rx from 'rxjs';
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
// import the module
|
// import the module
|
||||||
import * as smartrx from '../ts/index';
|
import * as smartrx from '../ts/index.js';
|
||||||
|
|
||||||
let testObservablemap: smartrx.Observablemap;
|
let testObservablemap: smartrx.Observablemap;
|
||||||
let testObservable1: rx.Observable<any>;
|
let testObservable1: rx.Observable<any>;
|
||||||
@ -21,12 +21,12 @@ tap.test('should create an instance', async () => {
|
|||||||
tap.test('should accept a new emitter', async () => {
|
tap.test('should accept a new emitter', async () => {
|
||||||
let done = smartpromise.defer();
|
let done = smartpromise.defer();
|
||||||
testEmitter = new events.EventEmitter();
|
testEmitter = new events.EventEmitter();
|
||||||
testObservable1 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
testObservable1 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||||
testObservable1.subscribe((x) => {
|
testObservable1.subscribe((x) => {
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
testObservable2 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event1');
|
testObservable2 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event1');
|
||||||
testObservable3 = testObservablemap.getObservableForEmitterEvent(testEmitter, 'event2');
|
testObservable3 = testObservablemap.getSubjectForEmitterEvent(testEmitter, 'event2');
|
||||||
expect(testObservable1 === testObservable2).toBeTrue();
|
expect(testObservable1 === testObservable2).toBeTrue();
|
||||||
expect(testObservable1 === testObservable3).toBeFalse();
|
expect(testObservable1 === testObservable3).toBeFalse();
|
||||||
testEmitter.emit('event1');
|
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';
|
import * as plugins from './smartrx.plugins.js';
|
||||||
export * from './smartrx.classes.observablemap';
|
export * from './smartrx.classes.observablemap.js';
|
||||||
export * from './smartrx.classes.observableintake';
|
export * from './smartrx.classes.observableintake.js';
|
||||||
import * as rxjs from './smartrx.plugins.rxjs';
|
import * as rxjs from './smartrx.plugins.rxjs.js';
|
||||||
export {
|
export {
|
||||||
rxjs
|
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
|
* ObservableIntake
|
||||||
@ -22,7 +22,7 @@ export class ObservableIntake<T> {
|
|||||||
private payloadBuffer: any[] = [];
|
private payloadBuffer: any[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.observable = rxjs.Observable.create((observerArg: rxjs.Observer<any>) => {
|
this.observable = new rxjs.Observable((observerArg: rxjs.Observer<any>) => {
|
||||||
this.observableFunctions.next = (...args: any) => {
|
this.observableFunctions.next = (...args: any) => {
|
||||||
return observerArg.next(args);
|
return observerArg.next(args);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
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';
|
||||||
|
|
||||||
export interface IEventEmitter<T = any> {
|
export interface IEventEmitter<T = any> {
|
||||||
on: (eventNameArg: string, eventHandlerArg: (eventPayload: T) => any) => void;
|
on: (eventNameArg: string, eventHandlerArg: (eventPayload: T) => any) => void;
|
||||||
@ -8,9 +8,9 @@ export interface IEventEmitter<T = any> {
|
|||||||
/**
|
/**
|
||||||
* bundles an observable with an emitter
|
* bundles an observable with an emitter
|
||||||
*/
|
*/
|
||||||
export interface IObservableEmitterBundle {
|
export interface IObservableEventBundle<T> {
|
||||||
observable: rxjs.Observable<any>;
|
subject: rxjs.Subject<any>;
|
||||||
emitter: IEventEmitter<unknown>;
|
eventRef: T;
|
||||||
event: string;
|
event: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,26 +18,56 @@ export interface IObservableEmitterBundle {
|
|||||||
* manages observables by making sure that only one observable is regsitered per event
|
* manages observables by making sure that only one observable is regsitered per event
|
||||||
*/
|
*/
|
||||||
export class Observablemap {
|
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.
|
* In case event has been registered before the same observable is returned.
|
||||||
*/
|
*/
|
||||||
public getObservableForEmitterEvent<T>(emitterArg: IEventEmitter<T>, eventArg: string) {
|
public getSubjectForEmitterEvent<T>(
|
||||||
const existingBundle = this.observableEmitterBundleArray.find((bundleArg) => {
|
emitterArg: IEventEmitter<T>,
|
||||||
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg;
|
eventArg: string
|
||||||
|
): rxjs.Subject<T> {
|
||||||
|
const existingBundle = this.observableEventEmitterBundleArray.find((bundleArg) => {
|
||||||
|
return bundleArg.eventRef === emitterArg && bundleArg.event === eventArg;
|
||||||
});
|
});
|
||||||
if (existingBundle) {
|
if (existingBundle) {
|
||||||
return existingBundle.observable;
|
return existingBundle.subject;
|
||||||
} else {
|
} else {
|
||||||
const emitterObservable = rxjs.fromEvent<T>(emitterArg as any, eventArg);
|
const emitterObservable = rxjs.fromEvent<T>(emitterArg as any, eventArg);
|
||||||
this.observableEmitterBundleArray.push({
|
const emitterSubject = new rxjs.Subject();
|
||||||
observable: emitterObservable,
|
emitterObservable.subscribe(emitterSubject);
|
||||||
emitter: emitterArg,
|
const newBundle: IObservableEventBundle<IEventEmitter> = {
|
||||||
|
subject: emitterSubject,
|
||||||
|
eventRef: emitterArg,
|
||||||
event: eventArg,
|
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
|
// 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';
|
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