nb-riot-rx-form - Reactive Functional Riot.js form validation with Bacon.js
Reactive functional form validation library for Riot.js Using Bacon.js + Immutable as internal model.
Installation
$ bower install nb-riot-rx-form
or
$ npm install nb-riot-rx-form
Even better, use my yeoman generator rtjs (Working on it at the moment 2016-11-14)
Breaking change in V1.1.0
The version pre-v1.1.0 injects data into the form name / form field property directly into the current tag scope.
That leads to some unexpected side effects when using with other mixin. As of V1.1.0 Everything will be wrap
inside the $
+ formName
namespace. Check the new example below for more information.
EXAMPLE
import 'nb-riot-rx-form'; // just import and it will taken care of the rest <!-- (1) provide the tag / mixin with configuration, see (2) below --> <!-- (3) form submit handler - note the parent onsubmit={parent.submitHandler} Please see below at the $rxOnSubmit event for more explanation --> <!-- normal input --> TEXT INPUT <!-- normal input --> NUMBER INPUT {$testForm.numberInput.$errors} <!-- normal input --> EMAIL INPUT <!-- with rx-validate option --> INPUT with Validate {$testForm.validateInput.$errors} <!-- checkbox --> CHECKBOX OPTION <!-- radio --> RADIO ONE TWO <!-- select --> SELECT SELECT {key} <!-- textarea --> TEXTAREA SUBMIT DISPLAY DATA LIVE textArea: {$testForm.textareaInput.$value} {$testForm.textareaInput.$valid} <!-- END OF HTML -->
The above example is taken from our gh-pages
for development. A much longer API doc and article explaining about it is coming to the wiki.
Development
Clone this repository to your dev machine. Then checkout the gh-pages
branch:
$ git checkout gh-pages
You will see all the source files and a gulpfile.js
, first install all dependencies:
$ npm install && bower install
Then start gulp:
$ gulp dev
Joel Chu 2016 London
@TODO
- Re-test with Riot V.3.
- new
nb-form
sub tag. The idea is like Angularng-form
- Re-organize how the export works. Apart from export just the tag, also export the mixin(s) and the new tag(s). This will allow user to construct their form like a lego.
- The underlying data model require re-architect. The problem is we do this completely re-active at the moment (nothing happen nothing change) but at the initial stage when we might want to have the data to pass around (regardless it's empty or not) so we need to grab all the available model then push back to the current tag / mixin level.