Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
getTopViewersStream.js
tmi.min.js
<script>
import { onMount } from 'svelte';
import { parseBadges, parseEmotes } from 'emotettv';
import getTopViewersStream from './getTopViewersStream';
import './tmi.min.js';
const maxMessages = 10;
let messages = [];
let channelName;
onMount(async () => {
const { channel, channelId } = await getTopViewersStream();
channelName = channel;

const client = new tmi.Client({ channels: [ channel ] });
client.connect();
client.on('message', async (channel, tags, message) => {
if (messages.length >= maxMessages) messages.shift();

const parsedMessage = await parseEmotes(
message,
tags.emotes,
channelId,
);
const text = parsedMessage.toHtml();

const parsedBadges = await parseBadges(tags.badges, channelId)
const badges= parsedBadges.toHtml();

messages = [ ...messages, { text, badges, tags } ];
});
});
</script>

<p>
{#if !messages.length}
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */