-
Notifications
You must be signed in to change notification settings - Fork 4
Porting from the legacy Geppetto
Geppetto-Meta introduces several backwards uncompatible changes from the legacy Geppetto.
- Monorepo: all supported library components are included in the geppetto-meta git repository
- Only Python backend (PyGeppetto)
- The frontend is divided into three libraries:
- @metacell/geppetto-meta-core: contains the model definitions and the model factory
- @metacell/geppetto-meta-ui: collection of ui components for neuroscience applications. Depends on geppetto-meta-core
- @metacell/geppetto-meta-client: evolution of the legacy geppetto-client. The new client still supports the websocket backend but it is less opinionated about application workflows. Uses Redux as messaging system and the application that uses Geppetto can add other layers of actions/reducers/middlewares. Has a new widget and layout system based on flexlayout.
There is no need anymore to follow the rigid structure of the geppetto-application. Now Geppetto is a proper library on npm: depending on the needs, any Javascript/Typescript project configuration can be used now (for instance, create-react-app).
A good strategy can also be to start by copying one of the projects under /examples.
geppetto-meta js libraries are now compiled and available on npm.
On package.json
"dependencies": {
...
"@metacell/geppetto-meta-client": "1.0.0-alpha1",
"@metacell/geppetto-meta-core": "1.0.0-alpha1",
"@metacell/geppetto-meta-ui": "1.0.0-alpha1",
...
}
Geppetto libraries dependencies are defined as peer dependencies. It is needed to add to the dependencies any dependency that are needed (some ui dependencies may not be needed depending on the project).
- @geppettoengine/geppetto-client/geppetto-client -> @metacell/geppetto-meta-client
- @geppettoengine/geppetto-client/geppetto-ui-> @metacell/geppetto-meta-ui
- @geppettoengine/geppetto-client/geppetto-core-> @metacell/geppetto-meta-core
- Most of the instance capabilities apis that relate to control logic, like:
- VisualCapability: changeColor, select, etc
- importValue, importType
- GEPPETTO variable. The GEPPETTO variable should not be used anymore to reference managers and apis. Imports are preferable.
- GEPPETTO.trigger
- -> dispatch redux actions
- Import and use the EventManager
- GEPPETTO.on, GEPPETTO.off
The suggested way to develop is to use yalc to link Geppetto to the application codebase. A working version of this is available in the react-sample-application.
Geppetto does not trigger automatic spinners anymore. The legacy way to call a spinner is:
GEPPETTO.trigger(GEPPETTO.Events.Show_spinner, "Spinner message")
And the spinner could be removed with
GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner);
The legacy approach is flawed as it does not support parallel events: the first Hide_spinner action coming hides it for all.
With the EventManager:
import EventManager from "@metacell/geppetto-meta-client/common/EventManager";
import * as GeppettoActions from '@metacell/geppetto-meta-client/common/actions';
EventManager.showSpinner("Creating instances", GeppettoActions.INSTANCES_CREATED)
The spinner will be hidden after the INSTANCES_CREATED is received.
A better solution in a new setting is to do everything inside a redux middleware and use dispatch/next:
import * as GeppettoActions from '@metacell/geppetto-meta-client/common/actions';
export const myMiddleware = ({ getState, dispatch }) => next => action => {
switch(action.type) {
case MY_ASYNC_ACTION:
next(GeppettoActions.waitData(`Loading model...`, action.type));
myAsyncCall().then(data => {
...
next(action); // This will hide the spinner
})
}
}