Skip to content

sammok83/ui5-mobx-mst

Repository files navigation

logo

ui5-mobx-mst

UI5 Reactive State Management Framework with MobX / MobX State Tree. Integrated with the latest Mobx 6 package.

Getting started

Install

With yarn:

yarn add ui5-mobx-mst

Or npm:

npm i ui5-mobx-mst -S

Configure

Register the following custom task in your project's ui5.yaml:

Local development usage:

  1. Install a middleware router, for example: ui5-middleware-route.

  2. Set the custom middleware accordingly:

server:
  customMiddleware:
    # Static source routing for mobx state tree resources 
    - name: ui5-middleware-route
      mountPath: /resources/thirdparty
      beforeMiddleware: compression
      configuration:
        path: node_modules 

Production usage:

  1. Configure your shims accordingly:
# For testing resources after deployment - third party libraries
specVersion: '2.2'
kind: extension
type: project-shim
metadata:
  name: thirdparty # this can be your project shim name
shims:
  configurations:
    ui5-mobx-mst: # name as defined in package.json
      specVersion: '2.2'
      type: module # Use module type
      metadata:
        name: ui5-mobx-mst
      resources:
        configuration:
          paths:
            /resources/thirdparty/ui5-mobx-mst/: ""  # location where modules are stored            
  1. Issue the following command to preload build for project and dependencies to "./dist"
ui5 build --all

In your UI5 app:

Example of defining it in Component.js

// Works for both configurations above 
sap.ui.define([
	"sap/ui/core/UIComponent",
	"thirdparty/ui5-mobx-mst/MobxModel"
], function(UIComponent, MobxModel) {
    ...
}

For older browser support, ui5-mobx-mst disables proxies by default:

mobx.configure({
    useProxies: "never"
});

If however, you want to override this, the mobx and mobxStateTree globals are available for you to do this, after you've loaded the MobxModel above.

About Mobx

👉 Official docs can be found at Mobx

About Mobx State Tree

👉 Official docs can be found at Mobx State Tree

About Mobx/Mobx State Tree and UI5 Integration

👉 Further reads:

Credits

  • Christian Theilemann @geekflyer, a former SAP™ Employee - for the Mobx - UI5 Integration inspiration
  • Leon van Ginneken @leon-vg for the Mobx State Tree - UI5 Integration inspiration

About

Mobx State Tree Library - UI5 Integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published