Giter Club home page Giter Club logo

reformed's People

Contributors

secundant avatar

Watchers

 avatar

reformed's Issues

`createField` - core

Basic implementation of static field factory, it must support disabled and defaultValue params to begin with.

const fieldA = createField(); // Field<unknown>
const fieldB = createField({ defaultValue: 10 });
const fieldC = createField({
  defaultValue: 10,
  disabled: $notAuthorized
});

sample({
  clock: loggedIn,
  target: fieldA.reset
});

[draft] Schema API

  • Should be implementation-agnostic
  • Should support sync and async
  • Can update values (when? submit/any condition?)

`combineFields`

const fields = combineFields({
  fields: {
    name: createField({ defaultValue: '' }),
    age: createField({ defaultValue: 0 })
  }
});

const nested = combineFields({
  fields: {
    a: createField({ defaultValue: 'foo' as const }),
    b: combineFields({
      fields: {
        c: combineFields({
          fields: {
            d: createField({ defaultValue: 'bar' as const })
          }
        })
      }
    })
  }
});

sample({
  clock: buttonClicked,
  source: $external,
  fn: external => ({ b: { c: { d: external } } }),
  target: nested.change
});

[draft] Submit API

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<?>

[draft] Validation API

  • Should support Effect
  • Modes variants - change, blur, submit
  • Modes combination - Field can contain multiple validation modes at same time
  • ? CombinedField - only submit?
  • ? DynamicField - implement API (maybe will be different issue)

`combineFields` - Interaction API details

  • combined.$modified - should we compute it from children without any conditions?
    • $modified in Field is staying true until field will be reset
    • Maybe configure that behavior?

[draft] `createForm`

  • should inherit logic from combineFields
  • should provide Submit API (not specified yet)
const form = createForm({
  fields: { name: createField(), ... },
  submit: ???
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.