Events

Provides the ability to subscribe to various events raised by the local database.


onChange(callback)

All changes

Invoke the given callback when the database has been changed.

Parameters

  • Name
    callback
    Type
    (PouchDB.Core.ChangesResponseChange<object>) => void
    Description

    A function which is called with an object indicating the changes feed.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onChange(changes => {
  console.log('Database has been changed', changes)
});

// Later, dispose
subscription.dispose();

onNoteChange(callback)

Note changes

Invoke the given callback when a note has been added, modified or deleted.

Parameters

  • Name
    callback
    Type
    (PouchDB.Core.ChangesResponseChange<Note>) => void
    Description

    A function which is called with an object indicating the changes feed.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onNoteChange(changes => {
  console.log('Note has been changed', changes)
});

// Later, dispose
subscription.dispose();

onBookChange(callback)

Book changes

Invoke the given callback when a notebook has been added, modified or deleted.

Parameters

  • Name
    callback
    Type
    (PouchDB.Core.ChangesResponseChange<Book>) => void
    Description

    A function which is called with an object indicating the changes feed.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onBookChange(changes => {
  console.log('Notebook has been changed', changes)
});

// Later, dispose
subscription.dispose();

onTagChange(callback)

Tag changes

Invoke the given callback when a tag has been added, modified or deleted.

Parameters

  • Name
    callback
    Type
    (PouchDB.Core.ChangesResponseChange<Tag>) => void
    Description

    A function which is called with an object indicating the changes feed.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onTagChange(changes => {
  console.log('Tag has been changed', changes)
});

// Later, dispose
subscription.dispose();

onFullTextIndexBuildStart(callback)

Full-text index creation start

Invoke the given callback when the app started building full-text search index.

Parameters

  • Name
    callback
    Type
    () => void
    Description

    A Function to be invoked.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onFullTextIndexBuildStart(changes => {
  console.log('Full-text search index building has been started')
});

// Later, dispose
subscription.dispose();

onFullTextIndexBuildEnd(callback)

Full-text index creation end

Invoke the given callback when the app finished building full-text search index.

Parameters

  • Name
    callback
    Type
    () => void
    Description

    A Function to be invoked.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onFullTextIndexBuildStart(changes => {
  console.log('Full-text search index building has been finished')
});

// Later, dispose
subscription.dispose();

onFullTextIndexBuildError(callback)

Full-text index creation error

Invoke the given callback when the app failed to build full-text search index.

Parameters

  • Name
    callback
    Type
    (error: Error) => void
    Description

    A function which is called with an error.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.

Example

const db = inkdrop.main.dataStore.getLocalDB()
const subscription = db.onFullTextIndexBuildStart(changes => {
  console.log('Full-text search index building has been failed')
});

// Later, dispose
subscription.dispose();
Can you help us improve the docs? 🙏

The source of these docs is here on GitHub. If you see a way these docs can be improved, please fork us!