@argantom/argantom
    Preparing search index...

    Argantom core state persistence.

    State Management

    Argantom core manages account state and persistance both device locally and optionally on a cloud service.

    The Core.init constructor takes a CoreStateCb callback function with CoreState data, or you can call Core.getState directly.

    When building an application, you'll want to pay attention to the CoreState components in order. First CoreState.accountState, second CoreState.cloudState, and finally, the CoreState.ledgerUpdate timestamp.

    AccountState Description Next Actions
    NeedsAccount We have no account data for this user. This could be a completely new user to the app, or a user on a new device that wants to connect to an existing cloud account. Call createLocalAccount if the user does not want a cloud account. Call createCloudAccount if the user wants to create a new cloud account. Call pullCloudAccount if the user want to connect this new device to an existing cloud account.
    NeedsLogin We have a locked account. The user must supply the password to decrypt it. Call login to decrypt the account data.
    AwaitAuth Pending authentication with the cloud server. Either we just created or pulled a cloud account, or we are awaiting authentication with an existing cloud account. Display a loading screen until the state changes again.
    LoggedIn The user is logged in. No further account state actions needed.
    CloudState Description Interface Hints
    Offline Not connected to the cloud. This state indicates we are using a local-only account. Inform the user that buying a cloud subscription will keep their data safe.
    Unsaved The user has written data that is not synced to the cloud. This state will be true for a short time after the user adds or edits ledger data. If this state persists for a long time, it could indicate that the user is offline, or there is a problem with their account.
    Saved The user's data is saved to the cloud. Display some kind of success or check mark to the user.

    This timestamp indicates ledger data has changed. If the value is strictly greater than the last value when the UI was rendered, the UI should be re-rendered to reflect updated ledger data.

    Index

    Methods

    • Get or create a ledger for a calendar year and currency unit.

      Parameters

      • unit: Unit
      • year: number

      Returns Ledger

    • Create a new cloud account. Returns payment URL that should be opened.

      Parameters

      • email: string
      • password: Uint8Array<ArrayBuffer>

      Returns Promise<URL>

    • Create a new local account.

      Parameters

      • password: Uint8Array<ArrayBuffer>

      Returns Promise<void>

    • Delete local account.

      Returns Promise<void>

    • Login.

      Parameters

      • password: Uint8Array<ArrayBuffer>

      Returns Promise<void>

    • Attempt to pull and login to an existing cloud account.

      Parameters

      • email: string
      • password: Uint8Array<ArrayBuffer>

      Returns Promise<void>