Impératif ~ Fonctionnel
Impératif ~ Fonctionnel
Impératif ~ Fonctionnel
| Characteristic | Imperative approach | Functional approach | 
|---|---|---|
| Programmer focus | How to perform tasks (algorithms) and how to track changes in state. | What information is desired and what transformations are required. | 
| State changes | Important. | Non-existent. | 
| Order of execution | Important. | Low importance. | 
| Primary flow control | Loops, conditionals, and function (method) calls. | Function calls, including recursion. | 
| Primary manipulation unit | Instances of structures or classes. | Functions as first-class objects and data collections. | 
Réactive
Réactive
              Réactive
              Réactive
              Réactive
FRP
FRP
Bacon
Bacon
Bacon
asEventStreamfromCallbackfromPromisefromBinderBacon
tchoutchou.plug streamtchoutchou.push 'run'Bacon
stream.toProperty()me.onValue() me.assign($el, 'val')me.and you me.or youchanges() sampledBy(stream)Bacon
obs.map (value) ->, obs.map '.target.value'obs.filter (value) ->obs.onValue obs.doAction '.preventDefault'obs.flatMap obs.scan(seed, accumulator)obs.log()Bacon
Bacon
Bacon.combineAsArray(stream, property)Bacon.combineTemplate({id: 1, username: userprop})Bacon.when
  [stream, event], (_, e) ->,
  [stream], ->
                Bacon.update null,
  [stream, property], (_, value) ->,
  [otherstream], (_) ->
                
              Dans la vraie vie…
Dans la vraie vie…
Dans la vraie vie…
passwordInput   = $pwd.asEventStream 'keyup blur'
passwordEntered = passwordInput.map (e) -> !! e.target.value
model.submitPassword.plug( $form.asEventStream 'submit'
  .doAction '.preventDefault'
  .filter passwordEntered )
passwordEntered
  .not()
  .assign $submit, 'attr', 'aria-disabled'
          