Skip to content

Deprecate this package for Svelte v3? #3

@klaussner

Description

@klaussner

The API of this package doesn't work anymore with Svelte v3. Luckily, using Tracker with the new version much easier, so we might not need svelte-tracker anymore. Here's a small example:

import { Tracker } from "meteor/tracker";
import { onDestroy } from "svelte";

const computation = Tracker.autorun(() => {
  // Use a reactive data source ...
});

onDestroy(() => {
  computation.stop();
});

The only thing that could be simplified/abstracted even more is the onDestroy lifecycle function:

// useTracker.js

export default function useTracker(fn) {
  const computation = Tracker.autorun(() => fn());
  onDestroy(() => computation.stop());
}
import { Tracker } from "meteor/tracker";
import useTracker from "./useTracker.js";

useTracker(() => {
  // Use a reactive data source...
});

But I'm not sure if the tiny useTracker function is worth its own package. 🤔

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