-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
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
Labels
No labels