@notcompose/molecule-rxjs 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export * from './subjectMolecule.js';
2
+ export * from './subjectAsState.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './subjectMolecule.js';
2
+ export * from './subjectAsState.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './subjectMolecule.js'\nexport * from './subjectAsState.js'\n"]}
@@ -0,0 +1,4 @@
1
+ import { type State } from '@notcompose/core';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ export declare function subjectAsState<T>(subject: BehaviorSubject<T>): State<T>;
4
+ //# sourceMappingURL=subjectAsState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjectAsState.d.ts","sourceRoot":"","sources":["../../src/subjectAsState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAEtC,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAOvE"}
@@ -0,0 +1,11 @@
1
+ import { DisposableEffect, rememberState } from '@notcompose/core';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ export function subjectAsState(subject) {
4
+ const state = rememberState(() => subject.value);
5
+ DisposableEffect([subject], () => {
6
+ const sub = subject.subscribe(value => { state.value = value; });
7
+ return () => sub.unsubscribe();
8
+ });
9
+ return state;
10
+ }
11
+ //# sourceMappingURL=subjectAsState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjectAsState.js","sourceRoot":"","sources":["../../src/subjectAsState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAc,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAEtC,MAAM,UAAU,cAAc,CAAI,OAA2B;IACzD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAChD,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;QAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAA,CAAC,CAAC,CAAC,CAAA;QAC/D,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AAChB,CAAC","sourcesContent":["import { DisposableEffect, rememberState, type State } from '@notcompose/core'\nimport { BehaviorSubject } from 'rxjs'\n\nexport function subjectAsState<T>(subject: BehaviorSubject<T>): State<T> {\n const state = rememberState(() => subject.value)\n DisposableEffect([subject], () => {\n const sub = subject.subscribe(value => { state.value = value })\n return () => sub.unsubscribe()\n })\n return state\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ export declare function subjectMolecule<T>(content: () => T): BehaviorSubject<T>;
3
+ //# sourceMappingURL=subjectMolecule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjectMolecule.d.ts","sourceRoot":"","sources":["../../src/subjectMolecule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AAItC,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAWvE"}
@@ -0,0 +1,16 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ import { GlobalSnapshot } from '@notcompose/core';
3
+ import { runMolecule } from '@notcompose/molecule';
4
+ export function subjectMolecule(content) {
5
+ const state = runMolecule(content);
6
+ const behaviorSubject = new BehaviorSubject(state.value);
7
+ GlobalSnapshot.observeStateWrites((writtenState) => {
8
+ if (state === writtenState) {
9
+ GlobalSnapshot.withoutReadObservation(() => {
10
+ behaviorSubject.next(state.value);
11
+ });
12
+ }
13
+ });
14
+ return behaviorSubject;
15
+ }
16
+ //# sourceMappingURL=subjectMolecule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subjectMolecule.js","sourceRoot":"","sources":["../../src/subjectMolecule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,MAAM,UAAU,eAAe,CAAI,OAAgB;IAC/C,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,MAAM,eAAe,GAAG,IAAI,eAAe,CAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IAC3D,cAAc,CAAC,kBAAkB,CAAC,CAAC,YAAY,EAAE,EAAE;QAC/C,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YACzB,cAAc,CAAC,sBAAsB,CAAC,GAAG,EAAE;gBACvC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACrC,CAAC,CAAC,CAAA;QACN,CAAC;IACL,CAAC,CAAC,CAAA;IACF,OAAO,eAAe,CAAA;AAC1B,CAAC","sourcesContent":["import { BehaviorSubject } from 'rxjs'\nimport { GlobalSnapshot } from '@notcompose/core'\nimport { runMolecule } from '@notcompose/molecule'\n\nexport function subjectMolecule<T>(content: () => T): BehaviorSubject<T> {\n const state = runMolecule(content)\n const behaviorSubject = new BehaviorSubject<T>(state.value)\n GlobalSnapshot.observeStateWrites((writtenState) => {\n if (state === writtenState) {\n GlobalSnapshot.withoutReadObservation(() => {\n behaviorSubject.next(state.value)\n })\n }\n })\n return behaviorSubject\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@notcompose/molecule-rxjs",
3
+ "version": "0.1.2",
4
+ "description": "notcompose molecule (rxjs integration)",
5
+ "type": "module",
6
+ "main": "./build/dist/index.js",
7
+ "types": "./build/dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./build/dist/index.d.ts",
11
+ "import": "./build/dist/index.js",
12
+ "default": "./build/dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "build/dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "@notcompose/core": "^0.1.0",
20
+ "@notcompose/molecule": "^0.1.0",
21
+ "rxjs": "^7.8.2"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/y9maly/notcompose.git",
30
+ "directory": "notcompose-molecule/notcompose-molecule-rxjs"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "test": "vitest run"
35
+ }
36
+ }