Skip to content

Add support for loading extra operators #31

@Widdershin

Description

@Widdershin

It would be nice if we could allow users to specify additional operators to be available with @cycle/time, so that users could create their own operators or so that we could ship some operators that are uncommonly used but can be added as needed.

One possible way we could do this is to create a makeTimeDriver function that takes an extras object:

import {makeTimeDriver} from `@cycle/time`;
import tween from `@cycle/time/extra/tween`;

const drivers = {
  Time: makeTimeDriver({extras: {tween}})
}

mockTimeSource could also take this extras object.

An extra would need to be a function that takes in the schedule object (used for adding to the schedule, like a listener), the currentTime() function, and possibly a function to get the time source (to allow building on top of core operators). It would need to return a function.

One thing I am unsure of is how to make this play nicely with TypeScript. Perhaps there is a way to tell TypeScript that there will be extra operators in the TimeSource from the provided extras object but I am unsure.

This is a prerequisite for #13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions