Skip to content

Commit

Permalink
chore(api): making configuration parameter optional for source()
Browse files Browse the repository at this point in the history
  • Loading branch information
razshare committed Jan 31, 2024
1 parent 5abb448 commit c843d1b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sveltekit-sse",
"version": "0.8.0",
"version": "0.8.1",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
Expand Down
2 changes: 1 addition & 1 deletion src/components/example.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { source } from '$lib/source.js'
const connection = source('/events', { beacon: 1000 })
const connection = source('/events')
const channel = connection.select('cat-quote')
/**
* @type {import('svelte/store').Readable<null|import('../routes/events/+server').Quote>}
Expand Down
7 changes: 5 additions & 2 deletions src/lib/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,13 @@ function defaultJsonOrPredicate({ error, previous }) {
* > })
* > ```
* @param {string} from Path to the stream.
* @param {SourceConfiguration} configuration
* @param {SourceConfiguration} [configuration]
* @returns
*/
export function source(from, { close, error, beacon = 5000, options = {} }) {
export function source(
from,
{ close, error, beacon = 5000, options = {} } = {},
) {
/** @type {SourceState} */
let state = {
eventsCounter: 0,
Expand Down
1 change: 0 additions & 1 deletion src/routes/events/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ async function dumpData({ emit, lock }) {
export function POST({ request }) {
return events({
request,
timeout: 3000,
start(connection) {
dumpData(connection)
},
Expand Down

0 comments on commit c843d1b

Please sign in to comment.