Skip to content

Conversation

@ayrtonandino
Copy link
Contributor

Changed the url parameter type from string to MaybeRefOrGetter<string> in @laravel/stream-vue.

This improvement allows developers to pass a Ref<string>, a Computed<string>, a getter Prop () => prop.url, or a plain string as the stream URL in useStream, useJsonStream and useEventStream.

Benefits to end users:

Enables full reactivity: when the URL changes dynamically, the composable automatically cancels the current stream and resets state without extra boilerplate.
Simplifies building reactive web applications by reducing mounting and unmounting components.

Small breaking changes:

Adds flexibility without altering the core API behavior, existing code that passes a plain string still works as before.

Upgraded minimun Vue version to v3.3.0 in package.json, required to use MaybeRefOrGetter and toRef, but this version is really old (released in 2023) and shouldn't make any difference.

Why it makes development easier:

Developers can now bind streams directly to reactive sources, improving maintainability and reducing complexity in Vue applications.

This options are now available:

// plain string, same as before
useStream("chat")
// reactive chatRoom with id from defineProps using getter
const props = defineProps<{ chatRoom: string|number }>()

useStream((): string => `chats/${props.chatRoom}`)
// complex reactive computed value
const getUrl = computed(
   (): string => `/api/${version.value}/${section.value}/profile/details/${detailLevel.value}/stream`
)

useStream(getUrl)

@joetannenbaum
Copy link
Collaborator

Looks good, thank you!

@joetannenbaum joetannenbaum merged commit 14118b1 into laravel:main Dec 2, 2025
2 checks passed
@ayrtonandino ayrtonandino deleted the make-vue-reactive branch December 4, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants