Skip to content
On this page

keepFresh since v0.8

Refreshes the data in a Query automatically or on demand.

Note

keepFresh operator refreshes only Queries that were started at least once. So, consider calling query.refresh on the app start.

Formulae

keepFresh(query, config)

Config fields:

  • automatically?: true to refresh the data in a Query automatically if any Store that is used in the Query creation is changed.
  • triggers?: Array of Events after which operator starts refreshing the data in the Query.
  • enabled?: since v0.11 Store with the current enabled state. Disabled keepFresh will not execute queries, instead, they will be treated as skipped. Can be true or false.
ts
import { keepFresh } from '@farfetched/core';

keepFresh(query, { automatically: true, triggers: [someExternalEvent] });

TIP

You can use any object that follows the @@trigger-protocol as a trigger in the keepFresh operator's field triggers.

Released under the MIT License.