A dynamic, Stream-based API for job scheduling in Dart, capable of processing on different triggers.

Related tags

Templates pendulum
Overview

Pendulum

A library for task-scheduling in Dart. Exports a Task class that returns Streams, with a number of versatile options to customize how Tasks are run.

Tasks take a Function (and a corresponding List argument) and run them asynchronously on a number of triggers. All methods return Streams, because of their versatility: Streams can be listened, canceled, or converted to other types.

Methods take inspiration from Quartz Scheduler.

Usage

A (very) simple usage example:

import 'package:pendulum/pendulum.dart';

void main() async {
  var task = Task<String>((List args) {
    return 'Simple process!';
  }, []);
  var task2 = Task<String>((List args) {
    return 'Delayed process!';
  }, []);
  var task3 = Task<String>((List args) {
    return 'Repeated process!';
  }, []);
  var watch = Stopwatch();

  // Simple process and listen.
  task.process().listen((var data) {
    print(data);
  });

  // Process after a delay of 5 seconds.
  watch.start();
  task2.processAfter(Duration(seconds: 5)).listen((var data) {
    print(data);
    watch.stop();
    print(watch.elapsedMilliseconds);
  });

  await Future.delayed(Duration(seconds: 10));

  // Repeatedly process every 5 seconds for 20 seconds.
  watch.reset();
  watch.start();
  task3
      .repeatIntervalFor(Duration(seconds: 20), Duration(seconds: 5))
      .listen((var data) {
        print(data);
        print(watch.elapsedMilliseconds);
      });
}

This is just the start of the features of Pendulum. To see all the methods and triggers, check out the API reference.

Simulated Tasks

Testing Pendulum can be a pain if you're using Tasks with DateTime arguments, because you have to wait for the DateTime to be reached to test. My solution to this problem is SimulatedTask:

  • Simulated Task uses a provided DateTime instead of DateTime.now()
  • You can 'fast-forward' to any point in time that you want using setNow(DateTime arg)

This is obviously an imperfect solution, and I'm welcome to suggestions as to alternatives.

Partners in Crime

While Pendulum works fine all on its own, there are some packages that can enhance its functionality. A few of them are listed below:

  • RxDart
    • Library for Stream extensions.
    • Can be used to enhance processor methods
  • Instant
    • Library for DateTime manipulation.
    • Many Pendulum triggers involve DateTimes
    • Can be used to adjust for timezones
  • Isolate
    • Library for isolate management.
    • While Pendulum runs async, one isolate might not be able to handle all the tasks.
    • Using the isolate load_balancer class to run tasks could thus save CPU.

Features and bugs

Please file feature requests and bugs at the issue tracker.


This package and its contents are subject to the terms of the Mozilla Public License, v. 2.0.
© 2019 Aditya Kishore
You might also like...

A Flutter application about finding a specific person for a job you're looking for to hire

flutter_app2 A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Dec 16, 2021

Job Protal App Built Using Flutter

Job Protal App Built Using Flutter

Job Portal Job protal app is a design implementaion of Job portal App designed b

Nov 24, 2022

Freelancemarketplaceapp - Kimber - Job & Freelancing Marketplace UI Kit For Flutter

Freelancemarketplaceapp - Kimber - Job & Freelancing Marketplace UI Kit For Flutter

Kimber - Job & Freelancing Marketplace UI Kit Overview Kimber, is a Job & Freela

Oct 16, 2022

Job-App - Linkedin Clone app built with flutter

Job-App - Linkedin Clone app built with flutter

linkedin_clone Linkedin_Clone app Android Mobile Application Screenshot Home Adm

Sep 13, 2022

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight Node.js based Bhagavad Gita API [An open source rest api on indian Vedic Scripture Shrimad Bhagavad Gita].

Gita Bhagavad Gita flutter app. Download App - Playstore Web Application About Bhagavad Gita app using flutter & Bhagavad-Gita-API is A lightweight No

Apr 5, 2022

A visualized dynamic programming for log collection based on flutter.

A visualized dynamic programming for log collection based on flutter. Pub使用 1. Depend on it Add this to your package's pubspec.yaml dependencies: mag

Nov 22, 2022

Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.

Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.

Official Flutter packages for Stream Chat Quick Links Register to get an API key for Stream Chat Flutter Chat SDK Tutorial Chat UI Kit Sample apps Thi

Dec 25, 2022

Dynamic Text Highlighting (DTH) package for Dart & Flutter.

Dynamic Text Highlighting (DTH) package for Dart & Flutter.

Dynamic Text Highlighting (DTH) This package is used to highlight, in a completely dynamic way, keywords, or phrases, wherever they are present in a s

Oct 3, 2022

Return a Stream that emits null and done event when didChangeDependencies is called for the first time.

Return a Stream that emits null and done event when didChangeDependencies is called for the first time.

did_change_dependencies Author: Petrus Nguyễn Thái Học Return a Stream that emits null and done event when State.didChangeDependencies is called for t

Nov 9, 2022
Owner
Aditya Kishore
Aditya Kishore
Flutter-job-app - Flutter UI Day 28 of 100 - Job App

Flutter UI Day 28 of 100 - Job App Getting Started git clone https://github.com/

Afifudin 2 Sep 23, 2022
A smartphone application called Easy Job goal is to make easier for businesses to find people who meet their standards as well as for job seekers to search for and choose from available positions .

Easy_Jobs 19SW54(MAD-Project) A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to ge

Muskan 2 Nov 6, 2022
Dynamic var - Dart dilinde dynamic ve var veri tiplerini anlamanızı kolaylaştıracak örnektir.

dynamic ve var arasındaki fark dynamic Tanımlanan değişkenin tipi daha sonra kod içerisinde değişebilir. Örneğin int olarak tanımlanan bir a değişkeni

Abdullah Sevmez 0 Jan 1, 2022
Dart library for decoding/encoding image formats, and image processing.

image Overview A Dart library providing the ability to load, save and manipulate images in a variety of different file formats. The library is written

Brendan Duncan 907 Dec 27, 2022
Imgix package for Dart. Imgix is a CDN service with support for realtime image processing and optimization.

Imgix package for Dart. Imgix is a CDN service with support for realtime image processing and optimization.

Nikkei Inc. 3 Jan 24, 2022
A ListView widget capable of pinning a child to the top of the list.

PinnableListView A Flutter ListView widget that allows pinning a ListView child to the top of the list. Demo Getting Started Define the list PinCont

Jan Hrastnik 2 May 17, 2020
A capable library for managing Windows tray icons in your Flutter app 🦋

skip to content A capable tray icon plugin for Windows. ?? package on pub.dev ?? source on github.com ?? dart docs api reference Manage multiple icon

Bent Hillerkus 5 May 27, 2022
A CustomPaint example where we can draw with different colors and different stroke sizes

CustomPaint A CustomPaint example where we can draw with different colors and different stroke sizes. A Flutter application which runs on iOS, Android

Behruz Hurramov 0 Dec 27, 2021
Flutter Job List Application UI - Day 31

Flutter Job List Application UI - Day 31 class Afgprogrammer extends Flutter100DaysOfCode { video() { return { "title": "Flutter Job List

Mohammad Rahmani 48 Dec 27, 2022
Flutter package to hide out whole application or sections if you are not paid for the job done.

not_paid Worried about your payment? Using this package you can provide a non paid version of your app to the client that consistently starts fading o

hd-motion 11 Nov 30, 2021