We're merging multiple philosophies. And we want to do it cleanly. Which philosophy has to yield? (i.e. there will be pain for some)
Applications and plugins should have a proper lifecycle.
constructor
: Applications are created when neededwillMount
: A Kibana app won't always render, called before renderingdidMount
: After plugin has rendered, you know haveel
availablewillUpdate
: Before new props, e.g. if core or plugins state has changeddidUpdate
: After new propswillUnmount
: When removing app
Maybe add render
to make it easier for React plugins:
render
: To render, defaults to<div />
constructor
: All plugins are created when Kibana starts upwillUpdate
: Receiving new props, e.g. if core or plugins state has changed
Both core and plugin state lives in Redux in core
- Within core it's normal action -> reducer flow.
- From plugins it's notifying about change, then core pulling changes.
Re-render plugins when state has updated. This will trigger willUpdate
and didUpdate
.
Also broadcast changes using a middleware? (If so, use Court's idea for specific broadcasts?)
Doing this it should be easy to include in Redux, Angular, and other apps.
We need to handle communication from core to plugin, from plugin to core, and from plugin to plugin.
State updates + lifecycle.
Is that enough?
TimePicker in core? Need to be able to update, e.g.
kibana.timepicker.setRefreshInterval(60)
Which end up in a "pure Redux action dispatch"?
Some plugins need to extend core, e.g. Security.
External api (aka actions) + state?
How do we get specific broadcast to work for plugins?
Strict pre-defined deps? Maybe something like:
dependsOn: ['plugin-1', 'app-1', 'app-3']
Is this actually needed?
Core must own routing. Use React Router v4. Need to inject Match
,
matchPattern
, Link
et al.
Features plugins have access to.
Does NOT have state.
const { Match, matchPattern } = kibana.routing
kibana.es.query('...')
kibana.ajax.get('...')
Plugins/applications must be able to build on their own.
Do whatever you want, as long as you end up with a set of built files.
Huge deps, such as Angular et al, might need to be excluded in the build process.
If so, we might need to have strict requirements, e.g. same version of Angular, Lodash, et al.
Verify versions at startup?
(It isn't optimal, but it is how it is.)
Always inject Kibana deps. A plugin should never be able to require something from Kibana core.
One idea for applications and plugins is to receive the base class:
export default function(KibanaApplication) {
return class MyKibanaApp extends KibanaApplication {
}
}
// aka
export default KibanaApplication =>
class MyKibanaApp extends KibanaApplication {
}