-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
107 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const getValueAtPath = (state: any, pathParts: Array<string>): any => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
let currentResult = state; | ||
let i = 0; | ||
while (currentResult && i < pathParts.length) { | ||
currentResult = currentResult[pathParts[i]]; | ||
i++; | ||
} | ||
|
||
if (i === pathParts.length) { | ||
return currentResult; | ||
} | ||
return undefined; | ||
}; | ||
|
||
export default getValueAtPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { default as getValueAtPath } from './getValueAtPath'; | ||
export * from './getValueAtPath'; | ||
|
||
export { default as reduxStateAtom } from './reduxStateAtom'; | ||
export * from './reduxStateAtom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { atom } from 'recoil'; | ||
|
||
const reduxStateAtom = atom({ | ||
key: 'redux-to-recoil:state', | ||
default: null, | ||
}); | ||
|
||
export default reduxStateAtom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
const selectorFromReselect = (): null => { | ||
console.log('selectorFromReselect: not implemented'); | ||
return null; | ||
import { RecoilValueReadOnly, selector } from 'recoil'; | ||
|
||
import { reduxStateAtom } from './internals'; | ||
|
||
let count = 0; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const selectorFromReselect = <ReturnType = any>( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
selectorFn: (reduxState: any) => ReturnType, | ||
): RecoilValueReadOnly<ReturnType> => { | ||
count++; | ||
|
||
const wrappedSelector = selector<ReturnType>({ | ||
key: `redux-to-recoil:selector:${count}${selectorFn.name}`, | ||
get: ({ get }) => { | ||
const reduxState = get(reduxStateAtom); | ||
const value = selectorFn(reduxState); | ||
return value; | ||
}, | ||
}); | ||
|
||
return wrappedSelector; | ||
}; | ||
|
||
export default selectorFromReselect; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters