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

Event listeners #746

Closed
Andreyco opened this issue Jul 8, 2018 · 4 comments
Closed

Event listeners #746

Andreyco opened this issue Jul 8, 2018 · 4 comments
Assignees
Labels

Comments

@Andreyco
Copy link
Collaborator

Andreyco commented Jul 8, 2018

Current Behavior

People complain about missing features e.g ability to register form level "on change" handler and so on...
Related issues #731, #669, #271, #231 and so on

Desired Behavior

Make it possible to create solutions in user land if form of "plugins" - components, yay!

Suggested Solution

Add ability to register event handler. This will open possibilities, keep Formik's codebase slim. Win win, I guess.

Who does this impact? Who is this for?

Consumers, package creators.

Describe alternatives you've considered

Your FormikPersist package. Which is great, if you only care about keeping changes in local storage. Speaking from my needs, I need to save changes on server. Throttling is not an option - you are either sending data too often, or not too often :)

Example for FormikUpdated

// Pseudocode

Formik {
  addEventListener(event, handler) {
    // register event handler
  }

  onBlur() {
    // do all stuff
    // call event listeners
  }
}

class FormikUpdated {
  constructor() {
    formik.addEventListener('blur', this.onBlur)
  }

  onBlur() {
    this.props.onUpdate(formik.values)
  }
}


<Formik>
  {() => (
    <FormikUpdated onUpdate={sendToServer} />
  )}
</Formik>
@jaredpalmer
Copy link
Owner

How is this different from formik-effect?

@Andreyco
Copy link
Collaborator Author

Andreyco commented Jul 8, 2018

granularity of control. formik-effect runs on every key press. In most cases you only need to know form changed on field submit - blur event. Thus, need to subscribe to events.

@stale
Copy link

stale bot commented Sep 6, 2018

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

@stale stale bot added the stale label Sep 6, 2018
@stale
Copy link

stale bot commented Sep 13, 2018

ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.

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

No branches or pull requests

2 participants