Skip to content

analogy

James edited this page May 29, 2017 · 1 revision
fluent

imagine there are 2 people by the water, & the goal is to make 10 splashes.

as with most skills, you get better at skipping rocks the more that you do it. a lot of people cannot skip rocks, or they do not like to skip rocks, but they can still throw rocks and make a splash. think of this like non-fluent/vanilla-calls

Chain.prop()
Chain.longer()
Chain.intoSomeShapes()

or throwing a really huge rock into the water, and getting the splashes to make more splashes.

Chain.from({
  prop: null,
  longer: null,
  intoSomeShapes: null,
})
fluent

using method chaining looks similar to skipping rocks

Chain
  .prop()
  .longer()
  .intoSomeShapes()

writing an application with a fluent interface allows people to use it all three ways, and you only have to write it one way.