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

Feat: add keepValues to initialize (closes #3649) #3817

Merged
merged 1 commit into from
Mar 2, 2018

Conversation

JPeer264
Copy link
Contributor

@JPeer264 JPeer264 commented Feb 5, 2018

I added the feature of #3649. Now I added just an option keepValues, but kept the initial values with the same flag. Should another flag keepInitial be set for this?

@JPeer264 JPeer264 changed the title Feat: add keepValues to initialize Feat: add keepValues to initialize (closes #3649) Feb 5, 2018
@codecov-io
Copy link

codecov-io commented Feb 5, 2018

Codecov Report

Merging #3817 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3817   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          70      70           
  Lines        1601    1609    +8     
======================================
+ Hits         1601    1609    +8
Impacted Files Coverage Δ
src/createReducer.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25ab6d9...9fe7958. Read the comment docs.

@swils
Copy link

swils commented Feb 8, 2018

This is a fantastic feature, and by coincidence exactly what I need right now :-) Anyone an idea on how long would it take for this be part of an official release?

@JPeer264
Copy link
Contributor Author

JPeer264 commented Feb 8, 2018

@swils happy to hear. As you also have a use case for this, would you more prefer to keep the initial values and values just with one option, or separately? Maybe like keepValues and keepInitial?

Also I guess this might take some time, regarding to other PRs. My temporarily solution (as I really need this right now) would be to fork this repo, merge this branch into master and directly add my repo as dependency in my node modules 😅

@swils
Copy link

swils commented Feb 14, 2018

Not sure if I understand what you mean by the difference between keepValues and keepInitial? 😄

@JPeer264
Copy link
Contributor Author

Like my PR is about keeping the values and the initials. So in the following example I have an already registered field aField.

formReducer: {
  myForm: {
	values: {
	  aField: 'some value',
    },
    initial: {
      aField: 'some initial value',
    },
  },
},

Current PR implementation
When I now initialize another field with the option { keepValues: true } it will keep both previous values and initials:

formReducer: {
  myForm: {
	values: {
	  aField: 'some value', // <- kept
      aNewField: 'new value',
    },
    initial: {
      aField: 'some initial value', // <- kept
      aNewField: 'new value',
    },
  },
},

Seperated options
So what if I don't want to preserve the old values and just keep the initials. I need separated options: { keepValues: true, keepInitial: true }:

Here with the option { keepInitial: true }

formReducer: {
  myForm: {
	values: {
	  // any old value is lost here
      aNewField: 'new value',
    },
    initial: {
      aField: 'some initial value',
      aNewField: 'new value',
    },
  },
},

Here with the option { keepValues: true }

formReducer: {
  myForm: {
	values: {
      aField: 'some value',
      aNewField: 'new value',
    },
    initial: {
	  // any old value is lost here
      aNewField: 'new value',
    },
  },
},

@erikras erikras merged commit b5240aa into redux-form:master Mar 2, 2018
@JPeer264 JPeer264 deleted the feat/keepValues branch March 2, 2018 09:18
@erikras
Copy link
Member

erikras commented Mar 2, 2018

Published in v7.3.0.

@swils
Copy link

swils commented Mar 3, 2018

Hmmm @JPeer264 no real opinion on this, I guess more options are better in this case?

@JPeer264
Copy link
Contributor Author

JPeer264 commented Mar 3, 2018

@swils ya it got merged now, so it is one option (keepValues) now.

@lock
Copy link

lock bot commented Jun 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants