Skip to content

Commit

Permalink
public version
Browse files Browse the repository at this point in the history
  • Loading branch information
josermarinr committed May 2, 2021
1 parent cdc2b4a commit 47bb24c
Show file tree
Hide file tree
Showing 44 changed files with 544 additions and 484 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@

## Motivation

this hook help to share state between many tabs, its multipurpose,
the motivation to do this type hook is beacause we arrive a new age
when the multiscreen are the normality in this time and we need adapte to that.
This hook helps to share the status among many tabs, it is multipurpose,
the motivation for making this type of hook is because we entered a new era
when having a lot of screens on your workstation is normal at this time and we need to adapt to that.

Constantly configuring hooks to save and share states, the idea of hook-cross-tab comes out, enabled to work with only 3 properties

## To use

call the hook inside the function and you need pass two props,
call the hook inside the function and you need pass three props,

first the key of your data, this will be the name of the data to be stored

first the kay of your data, this will be the name of the data will be store
second data, this hook accepts any data type

second the data, this hook accepting any type of data
third the option, it only accepts "local" for localstorage and "broadcast"

in this repo its use
example
```
const [todos, setTodos] = useCrossTabState("tareas", [])
key defaultdata
const [todos, setTodos] = useCrossTabState({
key: "tareas",
initialState: [],
option: "local
})
```
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// babel.config.js
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
};
10 changes: 3 additions & 7 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import type {Config} from '@jest/types';

const config: Config.InitialOptions = {
verbose: true,
// preset: 'ts-jest',
// transform: {
// '^.+\\.tsx?$': 'babel-jest',
// },
preset: 'jest-puppeteer',
preset: 'ts-jest',
transform: {
'^.+\\.tsx?$': "ts-jest",
}
'^.+\\.tsx?$': 'babel-jest',
},
};
export default config;
3 changes: 3 additions & 0 deletions lib/Broadcast/EventListener.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { BroadcastChannel } from "broadcast-channel";
export declare const EventListener: (channel: BroadcastChannel<any>, setState: (event: any) => void, state: any) => void;
//# sourceMappingURL=EventListener.d.ts.map
1 change: 1 addition & 0 deletions lib/Broadcast/EventListener.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions lib/Broadcast/EventListener.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Broadcast/EventListener.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/Broadcast/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function BroadcastState(stateKey: string, initialValue: any): any[];
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions lib/Broadcast/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions lib/Broadcast/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Broadcast/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/Localstorage/EventListener.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare const EventListener: (stateKey: string, setState: (element: any) => void) => void;
//# sourceMappingURL=EventListener.d.ts.map
1 change: 1 addition & 0 deletions lib/Localstorage/EventListener.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/Localstorage/EventListener.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Localstorage/EventListener.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/Localstorage/SavingData.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import React from "react";
export declare const SavingData: (defaultValue: any, stateKey: string, setState: (element: any) => void, state: any, NewSession: React.MutableRefObject<boolean>) => void;
export declare function saveData(stateKey: string, state: any): void;
//# sourceMappingURL=SavingData.d.ts.map
1 change: 1 addition & 0 deletions lib/Localstorage/SavingData.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions lib/Localstorage/SavingData.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Localstorage/SavingData.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/Localstorage/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function LocalStorageState(stateKey: string, defaultValue: any): any[];
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions lib/Localstorage/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/Localstorage/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Localstorage/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export declare function useCrossTabState(stateKey: string, defaultValue: any): any[];
interface UniversalStatePorps {
key: string;
initialState: any;
option: "local" | "broadcast";
}
export declare const UniversalState: ({ key, initialState, option }: UniversalStatePorps) => any[];
export {};
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified node_modules/@types/react/LICENSE
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion node_modules/@types/react/README.md
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions node_modules/@types/react/experimental.d.ts
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified node_modules/@types/react/global.d.ts
100644 → 100755
Empty file.
Empty file modified node_modules/@types/react/index.d.ts
100644 → 100755
Empty file.
Empty file modified node_modules/@types/react/jsx-dev-runtime.d.ts
100644 → 100755
Empty file.
Empty file modified node_modules/@types/react/jsx-runtime.d.ts
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions node_modules/@types/react/package.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 47bb24c

Please sign in to comment.