API Reference
Table of Contents
Platform
This interface provides information about the OS or runtime platform on which the app is running.
getType
Returns string PlatformType ('web' | 'server' | 'ios' | 'android' | 'windows' | 'electron')
setServerMode
Set the Platform to 'server'. Useful to see if the app is rendering on server due to SSR.
Parameters
modeboolean (optional, defaultfalse)
filtersObj
This is the main BlueRain context. Works as a backbone of whole system.
Properties
AppsAppRegistry Instance object of AppRegistry.ComponentsComponentRegistry Instance object of ComponentRegistry.ConfigsConfigRegistry Instance object of ConfigRegistry.EventsEventRegistry Instance object of EventRegistry.FiltersFilterRegistry Instance object of FilterRegistry.PluginsPluginRegistry Instance object of PluginRegistry.refsObject Contains references of objects created by different apps and pluginsbootFunction Function to boot the OS.
BootOptions
Options object that boot and bootOnServer methods expect.
Type: {apps: Array<BR.App>?, config: ConfigType?, renderApp: boolean?, plugins: Array<BR.Plugin>?, serverMode: boolean?}
Properties
appsArray<BR.App> An array of apps to loadconfigConfigType Configuration objectrenderAppboolean If set to false, BlueRain will not render the main app, instead it is up to the developer to render it. The App is returned from the boot function.pluginsArray<BR.Plugin> An array of plugins to loadserverModeboolean Set this flag to true when rendering during Server Side RenderingappsArray<BR.App>?configConfigType?renderAppboolean?pluginsArray<BR.Plugin>?serverModeboolean?
boot
Boots the OS and renders the main UI. Use it on the client side
Parameters
optionsBootOptions (optional, default{serverMode:false,renderApp:true})
Returns ComponentType<any>
Config
This is the default configuration set that is used at boot time.
Type: ConfigType
Properties
appsObject Configurations for appsappRoutePrefixstring [default: "/app"] This route will be prependded to all app routesdebugboolean [default: true, false if NODE_ENV="production"] Debug modedevelopmentboolean [default: true, false if NODE_ENV="production"] Development modelocalestring [default: "en"] App localepluginsObject Configurations for pluginstitlestring [default: "BlueRain OS"] Main title of the appthemestring Theme to customize styling
ResponsiveLayout
ResponsiveLayout component to create responsive layouts.
Parameters
propsResponsiveLayoutProps
Properties
windowSizestring The window size i.e. (xs|sm|md|lg|xl)defaultReact.Component The default component to render, if a current size component is not given.xsReact.Component The component to render when the screen size is extra-small.smReact.Component The component to render when the screen size is small.mdReact.Component The component to render when the screen size is medium.lgReact.Component The component to render when the screen size is large.xlReact.Component The component to render when the screen size is extra-large.
onLayout
Whenever the screen/window size changes, notify redux to update state.bluerain.window object.
App
Extends RX.Component
A BlueRain App base class
Properties
appNameString Name of the appslugString App's slug, used in to build URLcategoryString Category the App belongs todescriptionString App descriptionversionString App versionappRoutePrefixString Path that will be prepended before slug to build URL.pathString Path of the app's home page
Plugin
Base class of a plugin which is to be extended.
Properties
pluginNameString Name of the appslugString App's slug, used in to build URLconfigobject Plugin configurationscategoryString Category the App belongs todescriptionString App descriptionversionString App version
IndexPage
Returns the Index Page layout.
Returns React.Component The layout react component
NotFoundPage
Returns the 404 Page layout.
Returns React.Component The layout react component
WindowState
The state of current window or screen. Stored in bluerain.window in the redux store.
Type: {width: number, height: number, size: ("xs" | "sm" | "md" | "lg" | "xl")}
Properties
widthnumber The window widthheightnumber The window heightsize("xs"|"sm"|"md"|"lg"|"xl") The window size i.e. (xs|sm|md|lg|xl)widthnumberheightnumbersize("xs"|"sm"|"md"|"lg"|"xl")
AppRegistry
Extends MapRegistry
All system apps are stored in this registry
Properties
register
Register an App To be deprecated in 2.0.0
Parameters
appApp The BlueRain app to register
set
Register an App
Parameters
appApp The BlueRain app to register
registerMany
Register many apps at once
Parameters
initializeAll
Initialize all the registered apps
getComponentSchema
Returns the JSON schema of the main APPs component. This component renders all the routes of apps.To be deprecated in 2.0.0
Returns Object JSON Schema
getAllRoutes
Returns the JSON schema of the main APPs component. This component renders all the routes of apps.
Returns Object JSON Schema
ComponentRegistry
Extends MapRegistry
All system components are stored in this registry
Properties
register
Register a component with a name, a raw component than can be extended and one or more optional higher order components.To be deprecated in 2.0.0
Parameters
nameString The name of the component to register.rawComponentReactElement<any> Interchangeable/extendable component.hocsArray<ComponentRegistryHocItem> The HOCs to compose with the raw component.
set
Register a component with a name, a raw component than can be extended and one or more optional higher order components.
Parameters
nameString The name of the component to register.rawComponentReactElement<any> Interchangeable/extendable component.hocsArray<ComponentRegistryHocItem> The HOCs to compose with the raw component.Note: when a component is registered without higher order component,hocswill bean empty array, and it's ok!
addHocs
Adds higher order component to the registered component
Parameters
namestring The name of the registered component to whom hocs are to addedhocsArray<ComponentRegistryHocItem> The HOCs to compose with the raw component.
get
Get a component registered with set(name, component, ...hocs). Its accepts multiple component names.It iterates arguments and returns first found registered component.
Parameters
nameString The name of the component to get.
Returns (Function | ReactElement<any>) A (wrapped) React component
getRawComponent
Get the raw (original) component registered with registerComponent without the possible HOCs wrapping it.
Parameters
nameString The name of the component to get.
Returns (Function | ReactElement<any>) An interchangeable/extendable React component
replace
Replace a component with the same name with a new component or an extension of the raw component and one or more optional higher order components. This function keeps track of the previous HOCs and wrap the new HOCs around previous ones
Parameters
nameString The name of the component to register.newComponentReactElement<any>rawComponentReactElement<any> Interchangeable/extendable component.hocs...Function The HOCs to compose with the raw component.
Returns (Function | ReactElement<any>) A component callable with Components[name]Note: when a component is registered without higher order component, hocs will be an empty array, and it's ok! See https://lodash.com/docs/4.17.4#flowRight
ConfigRegistry
All system configs are stored in this registry
Properties
ConfigsTableObject Storage table of all configs
set
Set a Config
Parameters
keystringvalueany
get
Get a config value
Parameters
keystring
Returns any
register
Register a Config To be deprecated in 2.0.0
Parameters
configs{}
registerMany
Register many configs at once
Parameters
configs{}
EventEmitter
All system events are stored in this registry.It is using event emitter to emit and add events.
FilterRegistry
Extends MapRegistry
All system filters are stored in this registry
Properties
add
Add a filter function to a hook.To be deprecated in 2.0.0
Parameters
hookString The name of the hookfilterFunction The filter functionindexnumber The index where function should be placed in array of functions against the hook
set
Add a filter function to a hook.
Parameters
hookString The name of the hookfilterFunction The filter functionindexnumber The index where function should be placed in array of functions against the hook
remove
Remove a filter from a hook
Parameters
hookstringnamestringhookNamestring The name of the hookfilterNamestring The name of the function to remove
run
Successively run all of a hook's filters on an item
Parameters
hookString First argument: the name of the hookitemObject Second argument: the post, comment, modifier, etc.on which to run the filters
argsAny Other arguments will be passed to each successive iteration
Returns Object Returns the item after it's been through all the filters for this hook
HookRegistry
All system hooks are stored in this registry
Parameters
filtersevents
add
Add a filter function to a hook.
Parameters
run
Successively run all of a hook's functions on an item
Parameters
hookString First argument: the name of the hookmode("async"|"sync"|"both") Second argument: mode in which hook will run. If not given mode will be sync (optional, default'sync')argsAny Other arguments will be passed to each successive iteration
Returns Object Returns the item after it's been through all the filters for this hook
Registry
A generic Registry class in the BlueRain OS. Used to store data.
Parameters
namestring
set
Add an item to the Registry.
Parameters
replace
Replace an item in the Registry.
Parameters
keystring The key of the itemitemany The item to add
get
Get an item from the Registry by its key.
Parameters
keystring The key of the item
Returns any
has
Check if an item is registered.
Parameters
Returns boolean
remove
Remove a plugin from the registry
Parameters
PluginRegistry
Extends MapRegistry
All system plugins are stored in this registry
Properties
register
Register a Plugin To be deprecated in 2.0.0
Parameters
pluginPlugin The plugin to register
set
Register a Plugin
Parameters
pluginPlugin The plugin to register
registerMany
Register many plugins at once
Parameters
initializeAll
Initialize all the registered plugins
Last updated