Skip to content
Raine Revere edited this page Dec 28, 2019 · 23 revisions

em is a new project so documentation is limited.

  • Glossary - List of terms and definitions.
  • Utility - Guide to common data types and utility functions.

Understanding the Data Model

Although em is rendered as a hierarchy, the basic data structure is a graph rather than a tree. Edges connect thoughts and contexts. The main difference from a tree is that nodes may have multiple parents, or in em terminology, thoughts may appear in many contexts (just as contexts can contain many thoughts, thus a many-to-many relationship).

e.g. The thought with value 'x' appears in contexts ['A', 'B'] and ['C']:

  • A
    • B
      • x
  • C
    • x

The thought being edited is tracked by state.cursor, which is a Path. There are infinitely many paths to a thought, since the context view allows jumping across the hierarchy and circular paths are allowed. Generally paths are converted into contexts to do anything useful.

Given the string value of a thought, you can retrieve a Thought object from the underlying thoughtIndex using getThought. This object contains a list of its contexts.

Given a context (e.g. ['A', 'B']), you can retrieve its thoughts from the underlying contextIndex using getThoughts.

See Glossary and Utility for more details.

Data Storage/Persistence

Thoughts are stored in the underlying objects thoughtIndex and contextIndex, which map hashed values to contexts and hashed contexts to values, respectively. These structures are stored in the following locations:

  • state (Redux)
  • local (indexedDB via localForage)
  • remote (Firebase) [optional; if user is logged in]

The syncing logic is a bit ad hoc and in need of refactoring. Syncing is complex due to offline mode.

See: sync.js

Schema Versions

The version of the data schema is stored in schemaVersion, allowing for systematic migrations. See SCHEMA_* constants for specific version information.

Mobile Testing

Localhost can be tunneled to a public url for mobile testing purposes using ngrok.

To allow logins, the ngrok domain must be added to Firebase Authorized Domains.

ngrok http 3333
Clone this wiki locally