@textile/hub > Buckets > archiveWatch
Buckets.archiveWatch() method
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
archiveWatch watches status events from a Filecoin bucket archive.
Signature:
archiveWatch(key: string, callback: (reply?: {
id: string | undefined;
msg: string;
}, err?: Error) => void): Promise<() => void>;
Parameters
Parameter | Type | Description |
---|---|---|
key | string | Unique (IPNS compatible) identifier key for a bucket. |
callback | (reply?: { id: string | undefined; msg: string; }, err?: Error) => void |
Returns:
Promise<() => void>
Example
Watch deal state changes for a active bucket archive request.
import { Buckets } from '@textile/hub'
async function logChanges (buckets: Buckets, key: string) {
const log = (reply?: {id?: string, msg: string}, err?: Error | undefined) => {
if (err || !reply) return console.log(err)
console.log(reply.id, reply.msg)
}
buckets.archiveWatch(key, log)
}