Giter Club home page Giter Club logo

mobx-react-mvvm-example's Introduction

Introduction

React MVVM architecture powered by MobX.

This example is a simple crypto-currency price feed application. It uses websocket price data as a source (provided by binance publicly)

Objective:

  • MobX is powerful but too free to use. A team should have a standard & flexible architecture/patterns that works/scales from small to large use cases and yet simple to learn.
  • Encourage others to learn reactive data stream concept. (Highly recommended ReactiveX, i.e. RxJs, RxJava, RxSwift)
  • Utilizing functional programming to compose & transform reactive data stream to desired output or behaviour.

The Heart of MVVM

  • A ViewModel(VM) should have NO dependency of React and should have no idea what the view looks like.
  • A correct implementation of MVVM architecture should achieve 100% decoupled business logic / data flow from views.
  • A pure VM is much easier to test than a "React components with state logic".
  • VMs should be light & cheap and be easily re-implemented with the same interface that consumed by the view.
  • If you are using typescript, you can SAFELY compose the VM with a lot of programming skills(Mixins/Traits/Inheritance) heavily used in other language to reduce boilerplate drastically. Typescript compiler can really protect your code base. (Probably this will become the strongest reason to choose typescript over plain javascript)

Run/Edit in CodeSandbox

Live On GitHub Page: https://gaplo917.github.io/mobx-react-mvvm-example

Language CodeSandbox
Javascript + React Hooks Edit mobx-react-price-feed-mvvm-example
Javascript + Standard Class Component Edit mobx-react-price-feed-mvvm-example
Javascript + Standard Class Component + Optional Chaining Edit mobx-react-price-feed-mvvm-example
Typescript + Standard Class Component Edit mobx-react-price-feed-mvvm-example

Run in local

yarn install
yarn start

// go to http://localhost:8080

mobx-react-mvvm-example's People

Contributors

gaplo917 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.