Private
_resourcesAll the resources of the store
Private
Optional
agentCurrent Agent, used for signing commits. Is required for posting things.
Private
batchedList of resources that have parents that are not saved to the server, when a parent is saved it should also save its children
Private
clientPrivate
eventPrivate
findPrivate
injectedPrivate
notifyLets subscribers know that a resource has been changed. Time to update your views. Make sure the resource is a new reference, otherwise React will not rerender.
Private
randomPrivate
serverThe base URL of an Atomic Server. This is where to send commits, create new instances, search, etc.
A list of all functions that need to be called when a certain resource is updated
Private
webMapped from origin to websocket
Will be marked private in the future, please use addResources
Adds a Resource to the store and notifies subscribers. Replaces existing resources, unless this new resource is explicitly incomplete.
Optional
opts: AddResourcesOptsAlways fetches resource from the server then adds it to the store.
The resource URL to be fetched
Optional
opts: { Optional
body?: string | ArrayBufferHTTP Body for POSTing
Optional
fromFetch it from the /path
endpoint of your server URL. This effectively
is a proxy / cache.
Optional
method?: "GET" | "POST"HTTP Method, defaults to GET
Optional
noDo not use WebSockets, use HTTP(S)
Optional
setOverwrites the existing resource and sets it to loading.
Gets a resource by URL. Fetches and parses it if it's not available in the store. Not recommended to use this for rendering, because it might cause resources to be fetched multiple times.
Gets a resource by URL. Fetches and parses it if it's not available in the store. Instantly returns an empty loading resource, while the fetching is done in the background . If the subject is undefined, an empty non-saved resource will be returned.
Optional
subject: stringOptional
opts: FetchOptsInject a custom fetch implementation to use when fetching resources over http
Optional
init: RequestInitSends an HTTP POST request to the server to the Subject. Parses the returned Resource and adds it to the store.
Optional
data: string | ArrayBufferSets the current Agent, used for signing commits. Authenticates all open websockets, and retries previously failed fetches.
Warning: doing this stores the Private Key of the Agent in memory. This might have security implications for your application.
Registers a callback for when the a resource is updated. When you call
this
The method returns a function that you can call to unsubscribe. You can also unsubscribe by calling store.unsubscribe()
.
Registers a callback for when the a resource is updated. When you call
this
The method returns a function that you can call to unsubscribe. You can also unsubscribe by calling store.unsubscribe()
.
Unregisters the callback (see subscribe()
)
Uploads files to atomic server and create resources for them, then returns the subjects.
If using this in Node.js and it does not work, try injecting node-fetch using Store.injectFetch()
Some versions of Node create mallformed FormData when using the build-in fetch.
Generated using TypeDoc
An in memory store that has a bunch of usefful methods for retrieving Atomic Data Resources. It is also resposible for keeping the Resources in sync with Subscribers (components that use the Resource), and for managing the current Agent (User).