@wazapp/core
The core is the main element of Wazapp application. It delivers <App /> component which creates app's Owner. It use used to keep all your singleton instances, eg. Services.

API

App

The App component will integrate your app with Wazapp. Make sure to wrap your top level component with it.
Optionally, you can pass your own Owner instance to it, using owner property.

Example

1
import { App as Wazapp } from '@wazapp/core'
2
​
3
const MyApp = () => (
4
<Wazapp>
5
<IndexPage />
6
</Wazapp>
7
)
8
​
9
export default MyApp;
Copied!

Owner

The owner serves as a global registry for your application. It exposes two methods: lookup and register. Usually, you dont need to worry about them but may become hand if you would like to pre initialize your own service.
Owner is used by @wazapp/component to access and lazy instantiate services.

Methods

  • register(key: any, value: any) - register "memorize" any valye you want under whatever key you want
  • lookup(key: any) - withdraw the "memorized" value for specific key

Example

1
class MySingleton {
2
constructor(options) {
3
this.options = options;
4
}
5
}
6
​
7
owner.register(MySingleton, new MySingleton({ hey: 'wazapp' }));
8
​
9
const mySingletonInstance = owner.lookup(MySingleton);
Copied!
Last modified 1yr ago
Copy link
Contents
API
App
Owner