Class: App

App(optionsopt)

`App` contains the orchestration logic for the entirety of what is being displayed for a given app, including the app chrome like navigation. App communicates these changes to Components via events so that they may react. The [hello-world example](https://github.com/Transmutable/bink/blob/main/examples/hello-world/site.js) has the most basic App and the [components example](https://github.com/Transmutable/bink/blob/main/examples/components/site.js) is more complex.

Constructor

new App(optionsopt)

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}
Properties
Name Type Attributes Default Description
dom HTMLElement <optional>
div
Source:
Example

Set up a basic user administration page

import { AdminApp } from '{some path}/App.js'
import { UpdateBioComponent } from './UpdateBioComponent.js'
import { ResetPasswordComponent } from './ResetPasswordComponent.js'
import { UpdatePortraitComponent } from './UpdatePortraitComponent.js'
import { UserModel } from './UserModel.js'

class AdminApp extends App {
	constructor(){
		// Get user model (see DataObject, DataModel, and DataCollection docs)
		this.dataObject = new UserModel()
		this.dataObject.fetch().catch(err => { ... handle error ... })

		// Set up the masthead
		this._masthead = new MastheadComponent(
			undefined,
			{
				brand: 'Your Brand',
				brandAnchor: '/',
				menuItems: [
					{ name: 'Bio', anchor: '#' },
					{ name: 'Password', anchor: '#password' },
					{ name: 'Portrait', anchor: '#portrait' }
				]
			}
		).appendTo(this)

		// Set up three sub-views with Components (see Component docs)
		this._bioComponent = new UpdateBioComponent(this.dataObject).appendTo(this)
		this._passwordComponent = new ResetPasswordComponent(this.dataObject).appendTo(this)
		this._portraitComponent = new UpdatePortraitComponent(this.dataObject).appendTo(this)

		// Set up the Router (see Router docs)
		this._router = new Router()
		this._router.addRoute(/^$/, 'default')
		this._router.addRoute(/^password$/, 'password')
		this._router.addRoute(/^portait$/, 'portrait')
		router.addListener('blog-app', (routeName) => {
			switch (routeName) {
				case 'default':
					this._bioComponent.show()
					this._passwordComponent.hide()
					this._portraitComponent.hide()
					break
				case 'password':
					this._bioComponent.hide()
					this._passwordComponent.show()
					this._portraitComponent.hide()
					break
				case 'portrait'
					this._bioComponent.hide()
					this._passwordComponent.hide()
					this._portraitComponent.show()
					break
			}
		})
	}	
}

Members

dom :HTMLElement

Type:
  • HTMLElement
Source:

localizerGatheredData :boolean

Type:
  • boolean
Source:

localizerGathering

Source:

localizerGathering :boolean

Type:
  • boolean
Source:

router :Router

Type:
Source:

Methods

append(childComponent) → {App}

Adds the childComponent's `dom` to this Component's `dom`.
Parameters:
Name Type Description
childComponent Component
Source:
Returns:
- this App, handy for chaining
Type
App

removeComponent(childComponent) → {App}

Removes the childComponent's `dom` from this Component's `dom`.
Parameters:
Name Type Description
childComponent Component
Source:
Returns:
- this App, handy for chaining
Type
App