Skip to content

Commit

Permalink
feat: implement wire and hooks
Browse files Browse the repository at this point in the history
- wire
- useWire
- useWireValue
- useWireState
  • Loading branch information
smmoosavi committed Nov 3, 2019
1 parent 2b67943 commit 7bf363d
Show file tree
Hide file tree
Showing 18 changed files with 1,185 additions and 197 deletions.
4 changes: 4 additions & 0 deletions .libtonrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
filename: 'forminator-react-wire'
name: 'ForminatorReactWire'
globals:
react: React
react-dom: ReactDOM
mitt: mitt
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,22 @@
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@types/jest": "24.0.18",
"@testing-library/react-hooks": "^3.1.0",
"@types/jest": "24.0.20",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.9.3",
"husky": "3.0.9",
"libton-script": "0.11.2",
"lint-staged": "9.4.2"
"lint-staged": "9.4.2",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-test-renderer": "^16.11.0"
},
"dependencies": {
"mitt": "^1.2.0"
},
"peerDependencies": {
"react": "^16.10.0",
"react-dom": "^16.10.0"
}
}
24 changes: 0 additions & 24 deletions src/forminator-react-wire.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/index.test.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/**
* connect react components with wire
*
* @remarks
* provide {@link ForminatorReactWire} function that returns `forminator-react-wire` string
*
* @packageDocumentation
*/

export { ForminatorReactWire } from './forminator-react-wire';
export { _WireImpl } from './wire.impl';
export { useWire } from './use-wire';
export { useWireState } from './use-wire-state';
export { useWireValue } from './use-wire-value';
5 changes: 5 additions & 0 deletions src/is-initializer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function isInitializer<V>(
initialValue: V | (() => V),
): initialValue is () => V {
return typeof initialValue === 'function';
}
7 changes: 7 additions & 0 deletions src/is-set-state-action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SetStateAction } from 'react';

export function isSetStateAction<S>(
action: SetStateAction<S>,
): action is (prevState: S) => S {
return typeof action === 'function';
}
7 changes: 7 additions & 0 deletions src/subscribable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Subscribable<V> {
getValue(): V | undefined;
getValue(defaultValue: V): V;
getValue(defaultValue?: V): V | undefined;
setValue(value: V): void;
subscribe(callback: (value: V) => void): () => void;
}
3 changes: 2 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { Options } from './forminator-react-wire';
export { Subscribable } from './subscribable';
export { Wire } from './wire';
Loading

0 comments on commit 7bf363d

Please sign in to comment.