It would be nice if lit-analyzer allowed settings event listeners to (well-typed) asyncReplace instances. Here's a simple (though somewhat silly) example where the click function changes depending on the date (there's definitely better ways to do this but lit seems to accept this):
import {html, LitElement} from 'lit';
import {customElement} from 'lit/decorators.js';
import {asyncReplace} from 'lit/directives/async-replace.js';
async function *getUrl() {
while (true) {
const date = new Date();
const day = date.getDay();
yield "https://example.com/days/" + day;
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
@customElement('button-date')
export class ButtonDate extends LitElement {
render() {
return html`<button
@click=${asyncReplace(getUrl(), url => fetch(url as any))}>
submit today</button>`;
}
}
It would be nice if
lit-analyzer
allowed settings event listeners to (well-typed)asyncReplace
instances. Here's a simple (though somewhat silly) example where the click function changes depending on the date (there's definitely better ways to do this but lit seems to accept this):