-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature: Add new load paths to load only if data has not previously been loaded #144
Comments
After diving into an initial implementation of this, I think expansion of the feature is appropriate. Instead of just loading data if it is missing, which doesn't quite work as simplistically as it sounds for anything other than Each of the loads would need to be tuned uniquely for the kind of data being loaded. Data would only be loaded if necessary when each of the necessary criteria for a given type of load had been verified:
|
To support dynamic loading based on the loadedAt timestamp, each of the Additionally, for each entity, a |
* Refactor all actions into more files for easier management * Loads into load-*-actions.ts * CUURDS into create|update|upsert|replace|delete-actions.ts * DeleteByKeys into delete-by-key-actions.ts * Edits into edit-actions.ts * Selections into selection-actions.ts * Deselections into deselection-actions.ts + Add new *IfNecessary loader actions for each type of load + Add tsdoc to all load actions * Update library index/public api to reference all actions from new files * Update all otehr action references throughout library ^ Bump library version to 0.5.0-beta.3 Phase #1: This is an initial refactoring of action files for the if-necessary work Issue #144
* Introduce to `defaultMaxAge` to IEntityOptions + Add EntityAge with predefined common ages for use with `defaultMaxAge` * Update @entity decorator to support passing name in only or options or both > Move key decorator tokens into entity-tokens.ts > Extract entity decorator into its own file entity-decorator.ts > Extract key decorator into its own file key-decorator.ts * Update index/public api to reference all exports from new locations * Added EntityAge enum to public api * Removed all imports from '../..' Issues #144 #141
* Introduce to `defaultMaxAge` to IEntityOptions + Add EntityAge with predefined common ages for use with `defaultMaxAge` * Update @entity decorator to support passing name in only or options or both > Move key decorator tokens into entity-tokens.ts > Extract entity decorator into its own file entity-decorator.ts > Extract key decorator into its own file key-decorator.ts * Update index/public api to reference all exports from new locations * Added EntityAge enum to public api * Removed all imports from '../..' Issues #144 #141
* Introduce to `defaultMaxAge` to IEntityOptions + Add EntityAge with predefined common ages for use with `defaultMaxAge` * Update @entity decorator to support passing name in only or options or both > Move key decorator tokens into entity-tokens.ts > Extract entity decorator into its own file entity-decorator.ts > Extract key decorator into its own file key-decorator.ts * Update index/public api to reference all exports from new locations * Added EntityAge enum to public api * Removed all imports from '../..' Issues #144 #141
* Introduce to `defaultMaxAge` to IEntityOptions + Add EntityAge with predefined common ages for use with `defaultMaxAge` * Update @entity decorator to support passing name in only or options or both > Move key decorator tokens into entity-tokens.ts > Extract entity decorator into its own file entity-decorator.ts > Extract key decorator into its own file key-decorator.ts * Update index/public api to reference all exports from new locations * Added EntityAge enum to public api * Removed all imports from '../..' Issues #144 #141
+ Add LoadIfNecessary action + Add LoadAllIfNecessary action + Add LoadManyIfNecessary action + Add LoadPageIfNecessary action + Add LoadRangeIfNecessary action * Export new actions from public api + Add new operators for if necessary loads + Add new effects for if necessary loads * Include new effects in standard modules * Export new effects from public api + Add stateNameOfEntity utility function * Update builders to use new entityStateName function Issue #144
+ Add LoadIfNecessary action + Add LoadAllIfNecessary action + Add LoadManyIfNecessary action + Add LoadPageIfNecessary action + Add LoadRangeIfNecessary action * Export new actions from public api + Add new operators for if necessary loads + Add new effects for if necessary loads * Include new effects in standard modules * Export new effects from public api + Add stateNameOfEntity utility function * Update builders to use new entityStateName function Issue #144
When loading entities with any of the existing load actions, the loads will always occur and will always call the API. There may be times, such as when loading lookup tables, when the load should only occur if data has not been loaded previously.
This proposal recommends introducing a new set of actions for loads, alongside the existing actions, that would only actually be dispatched if no data has been previously loaded for the specified entity.
A new set of actions is proposed to maintain backwards compatibility and function, method and constructor signature standard with existing actions. Modifying existing load actions would be possible by adding a new parameter to allow the developer to flag whether they want to load only if data has not been previously loaded. That would introduce a breaking signature change to all of the load actions and related facade methods. A new set of actions ensures the new functionality can be introduced without breaking any existing use cases.
The proposed actions:
Only initiating actions should be necessary, as these new actions would be filtered in the corresponding effects if the
loadedAt
timestamp for the given entity is not nullish, thus preventing the load from actually occurring. Further, these new actions should in turn dispatch their corresponding sibling actions, rather than calling the entity service directly. This will ensure that the existing load flows will be utilized if theloadedAt
timestamps are indeed nullish.The text was updated successfully, but these errors were encountered: