Open NullVoxPopuli opened 1 year ago
How to do Polling with a resource:
import { resourceFactory, resource } from 'ember-resources';
class State {
// this part I don't know, and is specific to your use case
@tracked foo;
@tracked bar;
}
const Status = resourceFactory((pollingInternal = 10_000) => {
return resource(({ on }) => {
let state = new State();
async function getStatus() {
// make your request here
state.foo = "foo";
}
let interval = setInterval(getStatus, pollingInterval);
on.cleanup(() => clearInterval(interval));
return state;
});
});
and then in a component or something:
{{#let (Status) as |status|}}
{{status.foo}}
{{/let}}
or in js
class {
@use status = Status;
get foo() {
return this.status.foo;
}
}
Convert to tutorial:
Convert to tutorial:
If you absolutely must
Topics to cover
Convert to tutorial:
more glimmer features:
unbound
j/k: https://discuss.emberjs.com/t/the-status-of-unbound/11187
no one should use this
Integrations with bonkers libraries
"an" implementation for throttle here
casting:
@value={{String f.value}}
@value2={{Boolean f.value}}
Custom reactive collections that are efficient on memory demo here
From socials:
add proper <style>
tutorial chapters.
hopefully one of those two libraries allows for browser-only usage
ember / framework concepts:
localCopy: use with modals
composing resourcessanitizing HTML
native JS State / encapsulation
Convert to tutorial: