BlueRain OS
  • Introduction
  • API
    • API Reference
  • Guides
    • Apps
      • Installation
      • Creating an App
      • Configuration
    • Components
      • Registering Components
      • Extending Components
      • Replacing Components
      • Accessing Raw Components
      • Components & HoCs
    • Filters
      • Known Filters
    • Plugins
      • Installation
      • Configuration
      • Creating a Plugin
  • Miscellaneous
    • JSON to React
  • Plugins
    • Apollo
    • Internationalization
    • Material UI
    • React Router
    • Redux
    • Redux Devtools
    • Why Did You Update
Powered by GitBook
On this page
  • Usage
  • Accessing configurations inside App
  • Accessing App Configs via Context
  1. Guides
  2. Apps

Configuration

Some times apps may need to have custom configurations for different projects. For example, a Hello World app may have the option to have a customizable hello message.

Usage

App configurations can be added to the config object int bluerain.js file. Continueing on our "Hello World" app example, this is what it's custom configurations will look like:

// bluerain.js
{
    // ...
    config: {
        apps: {
            'hello-world': {
                'helloMessage': 'Hi World!'
            }
        }
    }
    // ...
}

To find out what configurations an app needs, please refer to the app documentation.

Accessing configurations inside App

The app specific configurations are passed to the initialize method of the app class at system boot time.

import { App } from 'bluerain-os';

class HelloWorldApp extends App {

    static appName = 'Hello World';
    static slug = 'hello-world';

    static initialize(config, ctx) {
        console.log(configs.helloMessage);
    }
}

Accessing App Configs via Context

App configs can also be accessed anywhere in the project through BlueRain context:

import { withBlueRain } from 'bluerain-os';

const SomeComponent = (props) => {

    const BR = props.bluerain;
    const Text = BR.Components.get('Text');
    const config = BR.Configs.get('apps.hello-world');

    return <Text>{config.helloMessage}</Text>
}

export default withBlueRain(SomeComponent);
PreviousCreating an AppNextComponents

Last updated 6 years ago