jide@squareknot.com / @jideosan ~ ian@squareknot.com / @ianmstew

Squareknot is a way to make beautiful, branching step by step guides.

We can learn a lot from each other by sharing our ideas and collaboratively working together to improve them

SQUAREKNOT

Project Viewer Requirements

  1. Three Application States

    Overview State, Step State, Branch State
  2. Component State

    States of Steps and Nodes depend on Application State
  3. Multiple Sources

    States are based on data models and user interaction

Stateful Architecture

  1. Core Backbone philosophy

    View is bound to a model; view updates when its model changes.
  2. Key Rule

    Each and every change to the DOM corresponds to a model change.
  3. Decoupled Implementation

    The view is only responsible for simple updates and broadcasting user interactions.
  4. What about presentation logic?

    Need a container that handles user interactions and updates the state.

Stateful Architecture

Application State

Application State: State Machine

Goal: Compute State based on Domain and User Interactions

Component State

Component State

Marionette.StateService

State-aware container for business logic

  • Creates its own state model by default
  • May instead bind to an existing model
  • Delegates set/get to its state model

Marionette.StateService

Usage

  1. Initialize state attributes with
    defaultState
    hash.
  2. Bind handlers to event emitters or models using
    this.bindEntityEvents(...)
    .
  3. Call
    this.stateSet(...)
    as the last statement of each handler.

Marionette.StateService

Installation

  1. https://github.com/Squareknot/marionette.state-service
  2. npm install marionette.state-service
  3. bower install marionette.state-service

Questions