
Problem/Motivation
When calling getObject it should be possible to indicate that new data should be fetched, even if the object already exists in the store.
Proposed resolution
Could indicate a required fetch with something like:
await store.getObject({
objectName: 'recipes',
id: '912e092f-a7d5-41ae-9e92-e23ffa357b28',
fetch: true
})
Maybe 'refresh' is a better parameter name in case the method to get data changes in the future?
Issue fork drupal_state-3240885
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Toggle MR activity (6 comments)Comment #2
brianperryComment #5
jayhuskins@brianperry here is a small adjustment that adds a
refresh
parameter to thegetObject
function. Should this parameter be added togetObjectByPath
as well? I do not need that functionality, but it could be nice to have.Comment #6
chrisfromredfinI took a look at this, and will mark as NR - not comfortable RTBC until you answer the question re: getObjectByPath. Thanks!
Comment #7
brianperryThanks for the contribution @jayhuskins (and the nudge @chrisfromredfin)! Haven't had a chance to take a close look at the MR but hope to do that soon. In the meantime, I do think adding the equivalent functionality to getObjectByPath would be useful.
added 1 commit
Compare with previous version
Comment #8
jayhuskins@brianperry Okay I added the refresh functionality to getObjectByPath as well.
Comment #9
coby.sher CreditAttribution: coby.sher at Pantheon commentedThanks @jayhuskins! Could you add tests for this functionality to drupalState.test.ts and getobjectByPath.test.ts? I think it will be good to go after that.
added 2 commits
Compare with previous version
Comment #10
jayhuskins@coby.sher the tests are up!
added 1 commit
Compare with previous version
@jayhuskins LGTM. I've added some documentation and an example in
main.ts
. @backlineint mind taking a look as well?Comment #11
coby.sher CreditAttribution: coby.sher at Pantheon commented@jayhuskins thank you! LGTM. I added some docs and an example in main.ts. Will have @brianperry take a look but it should be good to go.
approved this merge request
started a merge train
Comment #13
brianperryMerged and released as 2.7.0 https://www.npmjs.com/package/@gdwc/drupal-state/v/2.7.0
Thanks a ton for the contribution @jayhuskins and thanks for the review @chrisfromredfin and @coby.sher!
I think there is a lot that we could do in the future to better handle merging and updating data that already exists in the store, but this feature will go a long way in the meantime.