Skip to content

Added configurability for PersistenceProvider clearing of default state#4121

Draft
jskupsik wants to merge 2 commits intodevelopfrom
persistenceProviderPersistDefaultValue
Draft

Added configurability for PersistenceProvider clearing of default state#4121
jskupsik wants to merge 2 commits intodevelopfrom
persistenceProviderPersistDefaultValue

Conversation

@jskupsik
Copy link
Copy Markdown
Contributor

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

PersistenceProvider.create({
persistOptions: {
path: `${path}.columns`,
persistDefaultValue: true,
Copy link
Copy Markdown
Contributor Author

@jskupsik jskupsik Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation of Anslem's proposal:

Set to false for grid columns here -

Note that this can be easily overriden by users using the PersistOption for persistColumns:

persistColumns: { persistDefaultValue: false }

export interface Persistable<S> {
getPersistableState(): PersistableState<S>;
setPersistableState(state: PersistableState<S>): void;
defaultPersistableState?: PersistableState<S>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives the user full control of the defaultPersistableState without the need to create an exotic getPersistableState() method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ticket did not mention this. Is this strictly neccessary?

/**
* If true, the default state will be persisted just like any other state, by writing its value.
* Otherwise, the default state is represented by clearing/emptying the persisted value.
*/
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried hard to make this comment very clear - let me know if it can be improved.

Copy link
Copy Markdown
Member

@lbwexler lbwexler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag to short-circuit the erasure looks pretty straightforward and safe and I approve -- the more simple hooks we have like this, the better.

Not sure I understand how the defaultPersistableState would be used? Would we change our implementations of getPersistableState() in hoist itself?

export interface Persistable<S> {
getPersistableState(): PersistableState<S>;
setPersistableState(state: PersistableState<S>): void;
defaultPersistableState?: PersistableState<S>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ticket did not mention this. Is this strictly neccessary?

@amcclain
Copy link
Copy Markdown
Member

@jskupsik can you pls pick up on Lee's question here from last month?

@amcclain amcclain requested a review from ghsolomon December 13, 2025 19:09
@amcclain
Copy link
Copy Markdown
Member

@jskupsik + @ghsolomon would love to get this finalized / merged if we can - Jakub, Lee has an outstanding question here, and Greg wanted to get your eyes on it as our general persistence czar. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PersistenceProvider clearing of default state should be an explicit option on target

3 participants