lxsmnsyc / solid-labels

Simple, reactive labels for SolidJS
MIT License
243 stars 8 forks source link

Not working in `async` context #13

Closed geakstr closed 1 year ago

geakstr commented 1 year ago

In case if you try assign value received from awaited promise to solid-label macro variable, it won't set async for wrapper function:

let current = $signal(null);

async setter() {
  current = async load();
}

This will be transformed to:

_setcurrent(() => await note.load());

Though it should be something like this I guess?

await note.load().then(val => _setcurrent(() => val);
lxsmnsyc commented 1 year ago

Nice catch, this seems tricky to do, I could probably hoist the update value then append the setter transform, so ideally it would be:

const awaited = await note.load();
_setcurrent((_val) => _val = awaited);
lxsmnsyc commented 1 year ago

Should be fixed in 0.14.3