ivan-kleshnin / cyclejs-examples

CycleJS examples
121 stars 9 forks source link

1.6-form proposal #19

Closed robmcm closed 6 years ago

robmcm commented 8 years ago

I would like to see a form example involving dynamically loaded/populated form fields. Such as a list of area codes that update based on selected country or state, or a list of street names that update based on postal (zip) code.

Ideally these filtered values would be fetched asynchronously from the server which would add additional complexity to the form. I would be very interested to see how you would tackle this in cycle.js

Thanks

ivan-kleshnin commented 8 years ago

@robmcm hi. Thanks for your interest.

Such as a list of area codes that update based on selected country or state, or a list of street names that update based on postal (zip) code.

It's totally solvable with current architecture as we keep all form elements in state and can describe any dependency between them. Like "passwordAgain should be equal to password" or those you've described. It may be interesting / educational to add such example in 1.6, of course. I'll consider this.

Ideally these filtered values would be fetched asynchronously from the server which would add additional complexity to the form. I would be very interested to see how you would tackle this in cycle.js

This is different. I didn't approach data load architecture in CycleJS because I believe it's the hardest part (from my experience). I decided to inspect available solutions like GraphQL / Relay / PouchDB / ... first to see what they propose. By now, I've kinda finished with them (no general solution available). So I'm going to build over my React-Ultimate experience.

Before staring to mess with "data-load" I'd like to be ensured in the exact dataflow architecture (CRUD vs CRUD.alt). Also see my last comment in https://github.com/cyclejs/core/issues/259.

You should also inspect https://github.com/cyclejs/examples

robmcm commented 8 years ago

I decided to inspect available solutions like GraphQL / Relay / PouchDB / ...

I'm not too interested in the actual loading from an async resource, but more the fact that the form needs to be asynchronously updated based on a change in source data. This could be modeled in the example by just ticking a stream that switches between two different hard coded data sources (perhaps for suggested usernames?).

What I am trying to understand is how cycle.js would dynamically update the data backing a form. This raises issues such as updating the options in form elements, or having to change values based on the selected option no longer being available. All of the examples I have found so far have been based around hard coded form options, I am concerned that in order to implement dynamic backing data you would need to model it quite differently.

ivan-kleshnin commented 8 years ago

Sorry. I'm not sure I follow your explanation 😞

robmcm commented 8 years ago

Sorry let me try again :)

I am interested in seeing how to model the following using cycle.js

Summary: Form elements with dynamic options. Example: List of available usernames.

This perhaps isn't the best use case, but I wanted something that fitted with your example (as user sign up form).

Lets say that a list of usernames shows in a