Skip to content

Commit

Permalink
fix: fixed format
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Jan 12, 2025
1 parent 19fe589 commit 68c4f77
Show file tree
Hide file tree
Showing 67 changed files with 2,794 additions and 2,792 deletions.
56 changes: 29 additions & 27 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["**/dist/**"]
},
"formatter": {
"enabled": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["**/dist/**"]
},
"formatter": {
"enabled": true,
"indentWidth": 2,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
132 changes: 66 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
{
"name": "reactjrx",
"private": false,
"version": "0.0.0-development",
"type": "module",
"files": ["dist"],
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.umd.cjs"
}
},
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"watch": "vite build --watch",
"preview": "vite preview",
"prepublishOnly": "npm run build",
"semantic-release": "semantic-release",
"test": "vitest --typecheck",
"test:ci": "vitest run",
"tsc": "tsc",
"prepare": "husky && husky install",
"check": "npx @biomejs/biome check ."
},
"peerDependencies": {
"@tanstack/react-query": "5.x",
"react": "^18 || ^19",
"react-dom": "^18 || ^19",
"rxjs": "*"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^16.1.0",
"@types/node": "^22.10.2",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.0.0",
"husky": "^9.1.7",
"jsdom": "^26.0.0",
"lint-staged": "^15.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rollup-plugin-node-externals": "^8.0.0",
"rxjs": "^7.8.0",
"semantic-release": "^24.1.1",
"typescript": "^5.6.2",
"vite": "^6.0.6",
"vite-plugin-dts": "^4.2.1",
"vitest": "^2.1.8"
},
"repository": {
"type": "git",
"url": "https://github.com/mbret/reactjrx.git"
},
"lint-staged": {
"*": [
"biome check --no-errors-on-unmatched --files-ignore-unknown=true --write"
]
}
"name": "reactjrx",
"private": false,
"version": "0.0.0-development",
"type": "module",
"files": ["dist"],
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.umd.cjs"
}
},
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"watch": "vite build --watch",
"preview": "vite preview",
"prepublishOnly": "npm run build",
"semantic-release": "semantic-release",
"test": "vitest --typecheck",
"test:ci": "vitest run",
"tsc": "tsc",
"prepare": "husky && husky install",
"check": "npx @biomejs/biome check ."
},
"peerDependencies": {
"@tanstack/react-query": "5.x",
"react": "^18 || ^19",
"react-dom": "^18 || ^19",
"rxjs": "*"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^16.1.0",
"@types/node": "^22.10.2",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@vitejs/plugin-react": "^4.0.0",
"husky": "^9.1.7",
"jsdom": "^26.0.0",
"lint-staged": "^15.3.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rollup-plugin-node-externals": "^8.0.0",
"rxjs": "^7.8.0",
"semantic-release": "^24.1.1",
"typescript": "^5.6.2",
"vite": "^6.0.6",
"vite-plugin-dts": "^4.2.1",
"vitest": "^2.1.8"
},
"repository": {
"type": "git",
"url": "https://github.com/mbret/reactjrx.git"
},
"lint-staged": {
"*": [
"biome check --no-errors-on-unmatched --files-ignore-unknown=true --write"
]
}
}
28 changes: 14 additions & 14 deletions release.config.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module.exports = {
branches: ["main"],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
// https://github.com/semantic-release/semantic-release/issues/2204#issuecomment-1486299917
[
"@semantic-release/github",
{
successComment: false,
failTitle: false,
},
],
"@semantic-release/npm",
],
branches: ["main"],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
// https://github.com/semantic-release/semantic-release/issues/2204#issuecomment-1486299917
[
"@semantic-release/github",
{
successComment: false,
failTitle: false,
},
],
"@semantic-release/npm",
],
};
16 changes: 8 additions & 8 deletions src/lib/binding/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Observable } from "rxjs";

export type SubscribeSourceFactory<Data> =
| (() => Observable<Data>)
| (() => Observable<Data> | undefined)
| (() => Promise<Data>)
| (() => Data);
| (() => Observable<Data>)
| (() => Observable<Data> | undefined)
| (() => Promise<Data>)
| (() => Data);

export type SubscribeSource<Data> =
| SubscribeSourceFactory<Data>
| Promise<Data>
| Observable<Data>
| Data;
| SubscribeSourceFactory<Data>
| Promise<Data>
| Observable<Data>
| Data;
32 changes: 16 additions & 16 deletions src/lib/binding/useBehaviorSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ import { useConstant } from "../utils/react/useConstant";
* @see https://github.com/reactwg/react-18/discussions/19
*/
export const useBehaviorSubject = <S>(state: S) => {
const subject = useConstant(() => new BehaviorSubject(state));
const completed = useRef(false);
const stateRef = useRef(state);
const subject = useConstant(() => new BehaviorSubject(state));
const completed = useRef(false);
const stateRef = useRef(state);

useEffect(() => {
if (completed.current) {
subject.current = new BehaviorSubject(stateRef.current);
completed.current = false;
}
useEffect(() => {
if (completed.current) {
subject.current = new BehaviorSubject(stateRef.current);
completed.current = false;
}

return () => {
if (!completed.current) {
subject.current.complete();
completed.current = true;
}
};
}, [subject]);
return () => {
if (!completed.current) {
subject.current.complete();
completed.current = true;
}
};
}, [subject]);

return subject;
return subject;
};
10 changes: 5 additions & 5 deletions src/lib/binding/useLiveBehaviorSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useEffect } from "react";
import { useBehaviorSubject } from "./useBehaviorSubject";

export const useLiveBehaviorSubject = <S>(state: S) => {
const subject = useBehaviorSubject(state);
const subject = useBehaviorSubject(state);

useEffect(() => {
subject.current.next(state);
}, [state, subject]);
useEffect(() => {
subject.current.next(state);
}, [state, subject]);

return subject;
return subject;
};
16 changes: 8 additions & 8 deletions src/lib/binding/useObservableCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { useSubject } from "./useSubject";
* This creates an event handler and an observable that represents calls to that handler.
*/
export const useObservableCallback = <T = void>(): readonly [
Observable<T>,
(arg: T) => void,
Observable<T>,
(arg: T) => void,
] => {
const subject = useSubject<T>();
const subject = useSubject<T>();

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
const trigger = useCallback((arg: T) => {
subject.current.next(arg);
}, []);
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
const trigger = useCallback((arg: T) => {
subject.current.next(arg);
}, []);

return [subject.current, trigger] as const;
return [subject.current, trigger] as const;
};
20 changes: 10 additions & 10 deletions src/lib/binding/useObservableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import { useBehaviorSubject } from "./useBehaviorSubject";
* you need a direct reference to the value
*/
export const useObservableState = <T>(
defaultValue: T,
defaultValue: T,
): [Observable<T>, (value: T) => void, T] => {
const subject = useBehaviorSubject(defaultValue);
const subject = useBehaviorSubject(defaultValue);

const subject$ = useLiveRef(subject.current.asObservable());
const subject$ = useLiveRef(subject.current.asObservable());

const setState = useCallback(
(value: T) => {
subject.current.next(value);
},
[subject.current],
);
const setState = useCallback(
(value: T) => {
subject.current.next(value);
},
[subject.current],
);

return [subject$.current, setState, subject.current.getValue()];
return [subject$.current, setState, subject.current.getValue()];
};
Loading

0 comments on commit 68c4f77

Please sign in to comment.