Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FrintJS: Building Modular Apps with React and RxJS

FrintJS: Building Modular Apps with React and RxJS

For documentation, visit https://frint.js.org

Fahad Ibnay Heylaal

July 26, 2017
Tweet

More Decks by Fahad Ibnay Heylaal

Other Decks in Programming

Transcript

  1. Travix • Global online travel company • Multiple brands worldwide

    • Operating in 40+ countries • 500+ employees • Growing rapidly • Engineering based in Amsterdam and London • Firm believer in Open Source https://travix.com
  2. What is Frint? • An Open Source project • A

    Modular JavaScript framework • Consisting of multiple packages in a monorepo • Built primarily for the needs of Travix • Generic enough to be used anywhere (browser, server, CLI, outside of Travix) • Focused on providing minimum set of building blocks • Stable since v1.0 release, and already in production Site: https://frint.js.org GitHub: https://github.com/Travix-International/frint
  3. Packages in the monorepo • frint: The core package, for

    creating Apps • frint-react: React bindings and for rendering • frint-react-server: Server side rendering for Apps • frint-store: Reactice store for state management with actions and reducers • frint-model: Object-like data structures • frint-test-utils: Common reusable code for unit tests • frint-compat: Backwards compatibility support • frint-cli: CLI tool for FrintJS apps, with a pluggable system Coming soon: • frint-router: Services for streaming HTML5 history API, matching routes, etc • frint-router-react: React components for making SPAs • frint-data: Reactice Models and Collections, with Validation support
  4. Why do we need Frint? • Framework can align the

    development across all teams • Everyone building Apps the same way • Gives us control over what we allow and NOT allow to external developers • Ultimately gives us a foundation to build upon • Allows us to predictably keep backwards compatibility every quarter • Open Source & well maintained documentation for all • Code splitting
  5. Why not just use React or AngularJS directly? • Frint

    complements React (or any other functional rendering library) • The framework itself is very decoupled, and core is not directly tied to React • React is treated just as a rendering library by us • Frint takes care of the overall structure of your application • AngularJS is a full featured framework of its own • We needed to build on top of existing frontend (which is based on React) progressively • Starting from scratch in frontend was not an option
  6. Frint Apps • At least one (Root) App needed for

    Frint to work • There can be other Apps (Child) registering themselves to Root • Everything goes into your App as providers
  7. Streaming props to Components • Think props as a stream

    • Props stream emits new value, Component reacts to it and updates
  8. Regions • Areas that we define in our Components, where

    other Apps can render themselves • Done with the `<Region>` Component coming from `frint-react` package
  9. Root vs Child • They are both created the same

    way (with `createApp` function) • Root is rendered to DOM directly • Child is always registered to Root • Regions take care of rendering Child • There is always only one single Root App • No limit on number of Child apps
  10. Cascaded Providers • Providers defined in Root apps, made available

    (cascaded) to Child apps • It is opt-in, so you have to set `cascade` to true when defining the provider
  11. Two reserved provider names • app: The current Frint app

    that you are in • rootApp: The root app in the tree
  12. What if? • You cascade a provider, that needs to

    be scoped by the Child App that is consuming it? • Meaning, the value of the provider being cascaded, need to be computed again, and this time with the Child app as the value of `app` dependency
  13. $ mkdir frint-test $ cd frint-test $ npm install -g

    frint-cli $ frint init --example kitchensink $ npm install $ npm start
  14. frint-store • Like Redux, but with RxJS • State can

    be streamed • Actions: Payloads of plain objects • Reducers: Functions taking in payloads and current state, returning new state • Combine multiple reducers into one single root reducer • Apps have their own Stores • Docs: https://frint.js.org/docs/packages/frint-store/
  15. What’s next? • frint-router and frint-router-react: will be released in

    a few days Under consideration: • frint-data: for Models and Collections based data structures, with Schema and Validation support • frint-intl: for localization needs • frint-store: improved further with Epics
  16. Contributing to Frint is easy • It’s an Open Source

    project • Everything is done out in the open You can: • Submit well explained bug reports • Help out others in Issues • Improve documentation • Send Pull Requests for bug fixes • Ask questions • Propose new features and directions • Spread the word
  17. Useful Links • Docs: https://frint.js.org/ • Repository: https://github.com/Travix-International/frint • Issues:

    https://github.com/Travix-International/frint/issues • Npm: https://www.npmjs.com/package/frint • Twitter: https://twitter.com/frintjs • Medium: https://medium.com/tag/frintjs • REPL: https://frint.js.org/repl Other third-party libraries: • React: https://facebook.github.io/react/ • RxJS: http://reactivex.io/rxjs/