import { createEventSignal } from '@solid-primitives/event-listener' import { createReconnectingWS } from '@solid-primitives/websocket' import { For, createEffect, createSignal } from 'solid-js' import { wsEndpointURL } from '~/signals' export const Logs = () => { const [search, setSearch] = createSignal('') const [logs, setLogs] = createSignal([]) const ws = createReconnectingWS(`${wsEndpointURL()}/logs`) const messageEvent = createEventSignal<{ message: WebSocketEventMap['message'] }>(ws, 'message') createEffect(() => { const data = messageEvent()?.data if (!data) { return } setLogs((logs) => [ ...logs, (JSON.parse(data) as { type: string; payload: string }).payload, ].slice(-100), ) }) return (
setSearch(e.target.value)} />
log.toLowerCase().includes(search().toLowerCase()), ) : logs() } > {(log) => (
{log}
)}
) }