UI5 Reactive State Management Framework with MobX / MobX State Tree. Integrated with the latest Mobx 6 package.
With yarn
:
yarn add ui5-mobx-mst
Or npm
:
npm i ui5-mobx-mst -S
Register the following custom task in your project's ui5.yaml
:
-
Install a middleware router, for example: ui5-middleware-route.
-
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
- 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
- Issue the following command to preload build for project and dependencies to "./dist"
ui5 build --all
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.
👉 Official docs can be found at Mobx
👉 Official docs can be found at Mobx State Tree
👉 Further reads:
- 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