Skip to content

Latest commit

 

History

History
104 lines (76 loc) · 3.27 KB

api.md

File metadata and controls

104 lines (76 loc) · 3.27 KB

ddp_asyncio

DDPClient

DDPClient(self, url, event_loop=None)

Manages a connection to a server. It takes a URL as the first parameter, the optional second parameter specifies which event loop will be used.

The is_connected property is a boolean which can be used to determine if DDPClient is currently connected to a server.

connect

DDPClient.connect(self)

This coroutine establishes a connection to a server. It blocks until the connection is established or an exception is raised.

Raises ddp_asyncio.ConnectionError if the server reports a failure (usually caused by incomplatible versions of the DDP protocol.)

disconnect

DDPClient.disconnect(self)

Coroutine which disconnects from the server. Does nothing if called while not connected.

disconnection

DDPClient.disconnection(self)

Coroutine that blocks while connected to the server.

get_collection

DDPClient.get_collection(self, name)

Retrieve an existing Collection by name. If the Collection does not exist it will be created.

Subscription

Subscription(self, name)

Tracks the status of a subscription. The ready property can be used to determine if a subscription is ready. The error property can be used to determine if a subscription encountered an error.

wait

Subscription.wait(self)

This coroutine waits for the subscription to become ready. If the server responds with an error then a ddp_asyncio.SubscriptionError will be raised.

Collection

Collection(self, name)

Stores data published from a connected server.

Collections are read-only and function identically to a dictionary, with each item's _id as the key.

A Collection item's attributes can be accessed like a dictionarie or with dot-notation attribute access, i.e. "item.attr"

get_queue

Collection.get_queue(self)

Creates and returns a new asyncio.Queue to monitor changes to a Collection. When the collection changes, a CollectionEvent object containing a description of the change is pushed to the queue.

CollectionEvent

CollectionEvent(self, d)

Represents a change to a Collection.

There are three types of changes: additions, changes, and removals. The type property states the type of change that occurred.

Additions have the following properties: type: 'added' _id: id of added item fields: contents of added item The fields property can be accessed like a dictionary or using dot-notation attribute access.

Changes have the following properties: type: 'changed' _id: id of changed item fields: contents of changed item cleared: list of keys removed from the item

Removals have the following properties: type: 'removed' _id: id of removed item