Skip to content

On generator functions for skeleton screens #84

Answered by heapwolf
JaimeObregon asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah the docs could use some more materials in this area. Roughly (I haven't run this code), you could add your top level component and a it can have a child component with an async-generator renderer like this...

class MyAsyncComponent extends Tonic {
  click () {
    this.reRender()
  }

  async * render () {
    yield this.html`<tonic-loader></tonic-loader>`

    const data = await foobar()

    return this.html`
      <div>${data}</div>
    `
  }
}

class AppContainer extends Tonic {
  render () {
    return this.html`
      <div>
        <my-async-component></my-async-component>
      </div>
    `
  }
}

Tonic.add(MyAsyncComponent)
Tonic.add(AppContainer)

document.addEventListener('…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JaimeObregon
Comment options

@heapwolf
Comment options

@heapwolf
Comment options

Answer selected by heapwolf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants