Scaling State

Introduction

ConanState are normal plain javascript objects. this means that when you decide the scope of your state, you can do it as you would do for any normal object.

On top of that, you can leverage our application context from the DI to help you scope your state.

In summary, the state of your state can be:

Global

You can have global state, mainly you can either import it as a normal object or by leveraging our application context (DI)

Local

You can have local state to your component by just declaring it and using it locally to your component

Context

The moment you connect state, is stored in the context, this means that you can use the context state

Runtime

By composition you can have state that you use inlined in your JS

Component

You can leverage scoping locally the state at the top of your component renderer and have the renderers down the line leverage the context state

There seems to be a trend where you would have to pick not only what tool you would prefer to use to manage your state, but also, that would constraint you on how to scope the state then.

The biggest use case for this, are the libraries that push for state to be always global.

We think that is a mistake, any modern web application has state and being able to choose the adequate scope for it is very important.

Last updated