Dart - schedule()

Creates a new Schedule to run a service on a defined frequency.

import 'package:nitric_sdk/nitric.dart';

// Create a schedule that runs every 3 hours
Nitric.schedule("aggregate-data").every("3 hours", (ctx) async {
  print("do something here");

  return ctx;
});

Parameters

  • Name
    description
    Required
    Required
    Type
    String
    Description

    The unique name of this Schedule within the app. Subsequent calls to schedule with the same name will return the same object.

Notes

  • Schedules do not require access permissions to be specified.

  • During local development schedules can be triggered manually from the local development dashboard

Examples

Create a Schedule

import 'package:nitric_sdk/nitric.dart';

Nitric.schedule("send-reminders").every("3 minutes", (ctx) async {
  // add code to run here
  return ctx;
});

Nitric.schedule("archive-orders").cron("0 1 1 * *", (ctx) async {
  // add code to run here
  return ctx;
});