Skip to content

Programming Reference: ONMjs.AddressStore Class

ChrisRus edited this page Nov 9, 2013 · 2 revisions

Summary

Class ONMjs.AddressStore is a specialization of the ONMjs.Store used to store a single [ONMjs.Address][ProgrammingReference-AddressStoreClass] instance. The primary use case for ONMjs.AddressStore is to track the address of a selected data resource in client-side UI code.

For example, in the Encapsule Schema single-page test application an ONMjs.AddressStore instance is used to store the address of the data namespace currently selected by the user. Observer subroutines in this application monitor the selected address and react to changes in the address by dynamically rebinding their DOM views.

ONMjs.AddressStore instances, unlike ONMjs.Address instances, are associated with a specific ONMjs.Store instance. If an ONMjs.AddressStore instance contains an ONMjs.Address, then the addressed resource is guaranteed to exist in the associated ONMjs.Store.

Construction

    var addressStore = new ONMjs.AddressStore(referenceStore, address);

Parameters:

  • referenceStore - (required) reference to an ONMjs.Store (see remarks)
  • address - (optional) reference to an ONMjs.Address (see remarks)

Remarks:

An ONMjs.AddressStore instance has two states: defined and undefined. If in the defined state, ONMjs.AddressStore.getAddress will return a reference to the contained resource address that is guaranteed to exist in the ONMjs.Store specified by the referenceStore parameter. If in the undefined state, ONMjs.AddressStore.getAddress will return void 0 to indicate, typically, that there is no currently selected address.

Upon successful construction, ONMjs.AddressStore will register itself as an observer of the ONMjs.Store instance specified by referenceStore. If the data namespace addressed by the contained ONMjs.Address is removed from the reference store, ONMjs.AddressStore automatically updates itself with the parent address and initiates notification of its observers.

Properties

ONMjs.AddressStore.referenceStore

A reference to the ONMjs.Store instance associated with this stored address instance.

API Methods

ONMjs.AddressStore extends ONMjs.Store. The following methods are provided by the subclass in addition to base methods provided by ONMjs.Store.

ONMjs.AddressStore.getAddress

    var currentlySelectedAddress = addressStore.getAddress();

Remarks:

ONMjs.AddressStore.getAddress retrieves the ONMjs.Address stored in this instance, or returns void 0.

ONMjs.AddressStore.setAddress

    addressStore.setAddress(address);

Parameters:

Remarks:

If specified, the address parameter may be void 0 or the resolved ONMjs.Address of a namespace in the associated reference store.


Copyright (C) 2013 Christopher D. Russell