Skip to content
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

Infinite depth configuration #165

Merged
merged 1 commit into from
Oct 10, 2020
Merged

Infinite depth configuration #165

merged 1 commit into from
Oct 10, 2020

Conversation

GravlLift
Copy link
Contributor

This PR allows for more targeted configuration of state, removing the restriction that only top-level data can be stored. For instance, this is now a valid configuration:

export function localStorageSyncReducer(
  reducer: ActionReducer<any>
): ActionReducer<any> {
  return localStorageSync({
    keys: [
      {
        account: [
          { settings: [{ settingsGroup1: ['oneSettingInParticular'] }] },
        ],
      },
    ]
  })(reducer);
}

The above configuration would result in a localstorage value under the key account that looked like so, ignoring all other values in account, settings, or settingsGroup1:

{
  "settings": {
    "settingsGroup1": {
      "oneSettingInParticular": "value of setting"
    }
  }
}

Upgraded TS to 3.9.7
Added .editorconfig

@BBlackwo BBlackwo linked an issue Sep 5, 2020 that may be closed by this pull request
src/index.ts Outdated Show resolved Hide resolved
@BBlackwo
Copy link
Collaborator

BBlackwo commented Sep 5, 2020

Hi Jason @GravlLift,

Thanks so much for the PR! This is great. I love how you've cleaned up the code and added types.

Can you please:

  • Fix up the comments above (type consistency and adding a test)
  • Update the docs with an example config multiple levels deep.
  • Rebase off the lastest master and resolve the conflicts
  • Update your commit messages to follow the new required commit message format .
    You can do this with an interactive rebase. I'd also suggest squashing some of the commits together.
    Your new commit format should be something like feat: allow infinite depth configuration

Once you've made those changes I'll have another look.

@GravlLift
Copy link
Contributor Author

GravlLift commented Oct 4, 2020

All set @BBlackwo.

  • Fix up the comments above (type consistency and adding a test)
  • Update the docs with an example config multiple levels deep.
  • Rebase off the lastest master and resolve the conflicts
  • Update your commit messages to follow the new required commit message format .

Copy link
Collaborator

@BBlackwo BBlackwo left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all of those things! I've just got a few more minor comments if you can have a look please.

The only one that needs to be addressed is the deserialize function missing from the type. All the rest are optional.

You may want to squash the fixes together too.

Once that's addressed I'll merge it in and it will be automatically released as the next minor version.

spec/index_spec.ts Outdated Show resolved Hide resolved
src/lib/index.ts Outdated Show resolved Hide resolved
src/lib/index.ts Show resolved Hide resolved
src/lib/index.ts Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@GravlLift
Copy link
Contributor Author

Updated according to comments.

On an unrelated note, I'm not sure exactly how the commit/release note tool works, but it might be useful to apply that commit formatting restriction only to the master branch, and then simply squash PRs into a single commit with the correct formatting. That way you can have messy PR branches that you can update and commit as much as you like without restriction, but that mess gets condensed and removed into a single commit with a useful message when it goes to master. I'm rewriting the same commit over and over in this branch with force push anyways, so in essence you're losing that branch history regardless.

Just a suggestion.

@BBlackwo
Copy link
Collaborator

Thanks for fixing those up 👌

it might be useful to apply that commit formatting restriction only to the master branch, and then simply squash PRs into a single commit with the correct formatting.

That's a good idea. It looks like semantic release might not work well with squashed commits, sadly. But I'll keep it in mind!

@BBlackwo BBlackwo self-assigned this Oct 10, 2020
Copy link
Collaborator

@BBlackwo BBlackwo left a comment

Choose a reason for hiding this comment

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

Thanks so much for this enhancement, Jason @GravlLift!

@BBlackwo BBlackwo merged commit 37bf2bf into btroncone:master Oct 10, 2020
@BBlackwo
Copy link
Collaborator

🎉 This PR is included in version 10.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@BBlackwo
Copy link
Collaborator

Sorry it took so long for me to merge this in, btw. Appreciate your patience and continuing to address my comments months later.

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

Successfully merging this pull request may close these issues.

Saving nested state selectively (infinite depth)
2 participants