Refactor: mini-rx-store: use @mini-rx/common lib
spierala opened this issue · 0 comments
spierala commented
Background
The MiniRx Signal Store uses the same concept as the original RxJS-based MiniRx Store. As a result there is a lot of code which can be shared between the two store solutions. For that reason the @mini-rx/common lib was created. @mini-rx/common is already used by the Signal Store.
See here the full public API of @mini-rx/common: https://github.com/spierala/mini-rx-store/blob/master/libs/common/src/index.ts
Task
- Refactor MiniRx Store (mini-rx-store lib) to make use of the @mini-rx/common lib. Own custom implementations should be replaced with code from @mini-rx/common.
- All public API of @mini-rx/common should be used by mini-rx-store (if not used directly, at least some code should be re-exported. See the Signal Store exporting some code from @mini-rx/common: https://github.com/spierala/mini-rx-store/blob/master/libs/signal-store/src/index.ts#L24-L42)
- Signal Store should be used as orientation. In the end Signal Store and MiniRx Store should look quite identical. The main difference is that Signal Store is tailored to Angular Signals and MiniRx Store uses RxJS.
Subtasks
This is a quite large task. But is is definitely possible to create smaller sub-tasks:
- Refactor of the Redux Store (very similar to Signal Store store-core.ts: https://github.com/spierala/mini-rx-store/blob/master/libs/signal-store/src/lib/store-core.ts)
- Extensions (mostly remove and re-export)
- FeatureStore: use @mini-rx/common createFeatureStoreReducer, generateId, subsink, miniRxError, etc (see full list in Signal Store Feature Store: https://github.com/spierala/mini-rx-store/blob/master/libs/signal-store/src/lib/feature-store.ts#L2-L14)
- ComponentStore use @mini-rx/common createComponentStoreReducer etc (see full list in Signal Store Component Store: https://github.com/spierala/mini-rx-store/blob/master/libs/signal-store/src/lib/component-store.ts#L2-L20)
- Remove inheritance from Feature Store and Component Store: currently a BaseStore class is extended to share functionality between FS and CS. Signal Store uses the better and more lightweight approach (create methods individually from shared creation functions following a shared interface): https://github.com/spierala/mini-rx-store/blob/master/libs/signal-store/src/lib/component-store.ts#L87-L89
- Refactor Actions to align more with Signal Store
- Introduce
connect
method for FeatureStore and ComponentStore
Tests
mini-rx-signal store is covered by a lot of unit tests.
The tests will make the refactor relatively safe.
Indeed some tests can also be removed if mini-rx-store code is replaced with @mini-rx/common code.