[POST UPDATED]
Before, svelte-monetization uses named props to render monetized content:
svelte-monetization
{#if isLoading} <slot name="loading" /> {:else if isMonetized} <slot name="monetized" /> {:else} <slot name="not-monetized" /> {/if}
Now, while exploring Svelte docs, I've learned that you can pass values back to the parent using props too! So I refactored it.
<slot {isLoading} {isMonetized} />
Now it's much cleaner and can be used like this.
<SvelteMonetization let:isMonetized let:isLoading> {#if isLoading} <div>Loading message here</div> {:else if isMonetized} <div>Monetized/premium content here</div> {:else} <div>Show ads here</div> {/if} </SvelteMonetization>
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
[POST UPDATED]
Before,
svelte-monetization
uses named props to render monetized content:Now, while exploring Svelte docs, I've learned that you can pass values back to the parent using props too! So I refactored it.
Now it's much cleaner and can be used like this.