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

Form: Move out field handlers into subscription functions #365

Open
kettanaito opened this issue Feb 4, 2019 · 0 comments
Open

Form: Move out field handlers into subscription functions #365

kettanaito opened this issue Feb 4, 2019 · 0 comments
Labels
refactoring scope:architecture Changes affect architecture.
Projects
Milestone

Comments

@kettanaito
Copy link
Owner

Why?

Field handlers that exist as Form methods now do not need to access the form (except of to pass the form reference as the form argument). They can be isolated into own functions.

// Form.jsx
constructor() {
+ fromEvent('fieldChange').subscribe(handleFieldChange(this.eventEmitter, this))
}

- handleFieldChange() {...}
- handleFieldFocus() {...}
- handleFieldBlur() {...}

Subscription example:.

// utils/subscriptions/handleFieldChange.js
const handleFieldChange = (eventEmitter, form) = (eventPayload) => {
  const nextFieldState = foo(...)
  eventEmitter.emit('applyStatePatch', ..., ...)
}
@kettanaito kettanaito added scope:architecture Changes affect architecture. refactoring labels Feb 4, 2019
@kettanaito kettanaito added this to the 1.x milestone Feb 4, 2019
@kettanaito kettanaito added this to In scope in Roadmap Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring scope:architecture Changes affect architecture.
Projects
Roadmap
  
In scope
Development

No branches or pull requests

1 participant