BlueRain
Github
  • 💧Introduction
  • Overview
    • 📲Quick Start
    • 🎛️Configuration with bluerain.js
    • 🎡Lifecycle Events
    • 🛣️Roadmap
  • Key Concepts
    • 🔌Plugins
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🎣Hooks
    • 🎁Components
    • 📦BlueRain Modules
    • 🎛️Configs
    • 📈Analytics
    • 📔Logger
    • 🎨Themes
      • Installation
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • Registry
  • Guides
    • 🗿Icons
    • 🛂Migrating from V3
  • Components
    • Typography
    • Icons
      • Icon
      • DynamicIcon 📌
      • PluginIcon 📌
  • CLI
    • Expo
    • Web
    • Storybook (Web)
    • Storybook Native (Expo)
Powered by GitBook
On this page
  • New Version, New Name
  • Bye Bye, withBlueRain
  • No Singleton Instance
  • Hooks
  • Registry methods
  • Filter and Event Registries
  • Running a Hook
  • Plugins
  • Registry methods
  • Components
  • IconEnhanced
  1. Guides

Migrating from V3

PreviousIconsNextTypography

Last updated 6 years ago

BlueRain V4 is a complete rewrite of the whole framework. These have resulted in some major breaking changes. We made a conscious decision to go ahead with it since we a major version, we wanted to do what's right, rather than carry mistakes of previous version.

This page should serve as a guide to migrate BlueRain projects from V3.

New Version, New Name

The project name has changed in V4. Previous the framework was called BlueRain OS. We have decided to drop the OS part. So now, it's just BlueRain.

From V4 onwards, the project will move to it's new homes at:

Unfortunately, this also means that all import statements need to be migrated as well.

- import { BlueRain } from '@blueeast/bluerain-os';
+ import { BlueRain } from '@blueeast/bluerain';

Bye Bye, withBlueRain

Theres no easy way to say this but... withBlueRain HOC is gone! Use BlueRainConsumer component instead.

We did this to simplify the API and to keep the bundle size in check.

- const Button = withBlueRain(({ BR, ...rest }) => {
-     return <BR.Components.Button {...rest} />;
- });

+ const Button = (props) => (
+     <BlueRainConsumer>
+     {(BR) => <BR.Components.Button {...props} />}
+     </BlueRainConsumer>
+ );

No Singleton Instance

In V3 we used a single instance of BlueRain. This instance was exported from the library as default and BR. This has been removed in the V4. This means:

  • Now there is not default export in BlueRain 4.

  • Now there is no single BlueRain instance exported.

This also allows us to use more than one BlueRain apps in a single project.

Hooks

Registry methods

Since registry codebase has been completely revamped, the internal API and methods has changed. So, if you use any of the BR.Hooks class methods directly, be sure to check docs for changes.

Some important changes are listed below:

Add/Remove methods

add and remove methods have been renamed to register and unregister respectively.

Set method

Behavior of set and remove has changed.

  • set method sets the whole array of all listeners of a hook, as opposed to a single listener.

Filter and Event Registries

Hooks in V3 were made of 2 registries:

  • FilterRegistry

  • EventRegistry

Both of these have been removed, and we only have a single unified registry now, i.e. HookRegistry.

This also means that there are no BR.Filters and BR.Events properties in BlueRain context anymore.

Running a Hook

Return Type

- modifier = BR.Hooks.run('movies.edit', modifier);
+ modifier = await BR.Hooks.run('movies.edit', modifier);

Arguments in handler function

In V3 a hook handler function could receive any number of arguments. This has been changed and now a hook can only receive 3 fixed arguments.

- BR.Hooks.run('movies.edit', movie, actors, collections);
+ BR.Hooks.run('movies.edit', movie, { actors, collections });

Plugins

Registry methods

Since registry codebase has been completely revamped, the internal API and methods has changed. So, if you use any of the BR.Plugins class methods directly, be sure to check docs for changes.

Some important changes are listed below:

Add/Remove methods

add and remove methods have been renamed to register and unregister respectively.

Set method

Behavior of set and remove has changed.

  • set method sets the whole array of all listeners of a hook, as opposed to a single listener.

initializeAll method

initializeAll method has been removed. Use bluerain.plugins.initialize.all hook instead.

- BR.Plugins.initializeAll();
+ await BR.Hooks.run('bluerain.plugins.initialize.all', bootOptions);

registerMany method

registerMany method has been removed. Use bluerain.plugins.register hook instead.

- BR.Plugins.registerMany(plugins);
+ await BR.Hooks.run('bluerain.plugins.register', bootOptions);

Components

IconEnhanced

IconEnhanced Component has been renamed to DynamicIcon

All BR.Hooks.run now returns a that resolves a value, previously it just returned the value.

More details of about the arguments passed to the can be found here.

🛂
Github
NPM
Promise
We're calling it... BlueRain
handler function