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

[draft] Submit API #8

Open
secundant opened this issue Jan 17, 2023 · 0 comments · May be fixed by #9
Open

[draft] Submit API #8

secundant opened this issue Jan 17, 2023 · 0 comments · May be fixed by #9
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request scope:core
Milestone

Comments

@secundant
Copy link
Owner

Proposal:

const formA = createForm({
  fields: {},
  // ...
  submit: () => fetch()
});

const formB = createForm({
  submit: {
    mapParams: fields => ({ foo: 'bar', ...fields }),
    fn: fetchFx
  }
});

const formC = createForm({
  submit: {
    source: { foo: $foo },
    mapParams: (fields, fromSource) => ({ ...fromSource, ...fields }),
    fn: fetchFx
  }
});

formC.$submitStatus; // Store<'initial' | 'pending' | 'done' | 'fail'>
formC.$succeeded; // Store<boolean>

formC.submitted.success; // Event<?>
formC.submitted.failure; // Event<?>
formC.submitted.finally; // Event<?>
@secundant secundant added documentation Improvements or additions to documentation enhancement New feature or request scope:core labels Jan 17, 2023
@secundant secundant added this to the 0.1.0 milestone Jan 17, 2023
@secundant secundant self-assigned this Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request scope:core
Projects
None yet
1 participant