Giter Site home page Giter Site logo

Migrate to Runes about layercake HOT 6 OPEN

saabi avatar saabi commented on June 7, 2024
Migrate to Runes

from layercake.

Comments (6)

mhkeller avatar mhkeller commented on June 7, 2024 4

Thanks for letting me know. Iā€™m waiting for the full Svelte 5 release before figuring out what form LayerCake takes. Given that the library is a collection of stores and stores are no more, it will mean a significant rewrite.

from layercake.

mhkeller avatar mhkeller commented on June 7, 2024 3

Great ā€“ thanks for the offer! The first approach I plan on trying will be to replace every store with a $state rune and then instead of derived stores, use $derived. I haven't seen any examples on how runes interact with contexts, though.

Slots are also deprecated so there will have to be some changes there, too. It looks like the existing syntax may work if layout components render a children snippet.

But since Svelte 5 is still a moving target, I think it's better to wait until it settles.

from layercake.

mhkeller avatar mhkeller commented on June 7, 2024 2

There's a PR for making this compatible with Svelte 5. I may merge it or may wait until 5.0.0 is out: #190

edit: this has been merged and the library is compatible with Svelte 5

from layercake.

mhkeller avatar mhkeller commented on June 7, 2024 2

A note on the timing for this: Since the library is compatible with Svelte 4 and 5 but a migration to runes will cut off support for anything less than Svelte 5, I'm not in a huge rush to do that. It may make most sense to wait for something like Svelte 6 when some of the features Layer Cake uses become deprecated.

The goal here being that it works for the largest number of people.

from layercake.

mhkeller avatar mhkeller commented on June 7, 2024 1

FYI the existing LayerCake library works out of the box in Svelte 5 projects. That PR clears up some peerDependency warnings.

Eventually I will port LayerCake to using runes but it will require changes to component API. Using $state runes, you can no longer destructure values from contexts like you can with stores

import { getContext } from 'svelte';
const { xGet, yGet } = getContext('LayerCake');

// becomes...

const chart = getContext('LayerCake')
chart.xGet
chart.yGet

I may include a helper so you're not interacting with getContext directly

import { LayerCake, Svg, getChart } from 'layercake';

const c = getChart();

c.xGet
c.YGet

The design is still TBD but that approach seems to help with the ergonomics. Feedback welcome.

from layercake.

saabi avatar saabi commented on June 7, 2024

I may be able to help out with that... I do dataviz, performance and low level for a living. Check out https://github.com/nestauk/svizzle It doesn't use LayerCake (yet) but a port is planned.

It will have to wait for a new LayerCake release however.

from layercake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.