-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Farzin/R&D/80379/Extract cashier hooks into packages #6854
Farzin/R&D/80379/Extract cashier hooks into packages #6854
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
@@ -0,0 +1,16 @@ | |||
{ | |||
"name": "@deriv/api", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package will be replaced by @deriv/deriv-api
in the future as we move to TS and probably will have useWS
and useSubscription
hooks inside the @deriv/deriv-api
package itself.
I've extracted useWS
and useSubscription
hooks from the cashier
to this package so other packages can reuse
these hooks.
declare module '@deriv/stores' { | ||
export function useStore(): TRootStore & { | ||
modules: { | ||
cashier: CashierStore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we override the TRootStore
type that is returned from the useStore
hook to add CashierStore
types to it.
In the future cashier will have its own stores scoped to cashier instead of putting them in the root store so we will be removing this part.
export type TRootStore = TRootStoreBase & { | ||
modules: { | ||
cashier: CashierStore; | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, We override the TRootStore
type from the @deriv/stores
package to add CashierStore
types to it.
Once we removed the connect
method in cashier
we will be able to remove this part.
export type TClientStore = TRootStore['client']; | ||
export type TCommonStore = TRootStore['common']; | ||
export type TUiStore = TRootStore['ui']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just re-exporting the types as they are used directly inside cashier components, Once we remove the connect
method we can remove this part as well.
@@ -0,0 +1,16 @@ | |||
{ | |||
"name": "@deriv/hooks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will add all generic and reusable hooks inside this package to be accessible by other workspaces.
@@ -0,0 +1,15 @@ | |||
{ | |||
"name": "@deriv/stores", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we will be moving all the global states (aka RootStore
) to this package, Then other workspaces will be able to just install this package and have access to the stores instead of injecting the stores as a prop to each package.
toggleCashier: () => void; | ||
}; | ||
|
||
export type TRootStore = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since for now, the root store exists in the core
package, We cannot just infer the type and we have to manually type everything, As we gradually move stores from core to this package we will be able to remove these types and just infer the types instead.
Codecov Report
@@ Coverage Diff @@
## develop #6854 +/- ##
===========================================
- Coverage 21.65% 21.63% -0.02%
===========================================
Files 1454 1457 +3
Lines 33493 33499 +6
Branches 5794 5795 +1
===========================================
- Hits 7252 7249 -3
- Misses 25772 25780 +8
- Partials 469 470 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Changes:
Please include a summary of the change and which issue is fixed below:
When you need to add unit test
When you need to add integration test
Test coverage checklist (for reviewer)
Type of change