New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remix-utils

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remix-utils - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

4

browser/react/use-event-source.d.ts
declare type EventSourceOptions = {
init?: EventSourceInit;
event: string;
event?: string;
};

@@ -11,3 +11,3 @@ /**

*/
export declare function useEventSource(url: string | URL, options?: EventSourceOptions): string | null;
export declare function useEventSource(url: string | URL, { event, init }?: EventSourceOptions): string | null;
export {};

@@ -8,8 +8,7 @@ import { useEffect, useState } from "react";

*/
export function useEventSource(url, options) {
export function useEventSource(url, { event = "message", init } = {}) {
const [data, setData] = useState(null);
useEffect(() => {
var _a;
const eventSource = new EventSource(url, options === null || options === void 0 ? void 0 : options.init);
eventSource.addEventListener((_a = options === null || options === void 0 ? void 0 : options.event) !== null && _a !== void 0 ? _a : "message", handler);
const eventSource = new EventSource(url, init);
eventSource.addEventListener(event !== null && event !== void 0 ? event : "message", handler);
function handler(event) {

@@ -22,4 +21,4 @@ setData(event.data || "UNKNOWN_EVENT_DATA");

};
}, [url, options]);
}, [url, event, init]);
return data;
}
declare type EventSourceOptions = {
init?: EventSourceInit;
event: string;
event?: string;
};

@@ -11,3 +11,3 @@ /**

*/
export declare function useEventSource(url: string | URL, options?: EventSourceOptions): string | null;
export declare function useEventSource(url: string | URL, { event, init }?: EventSourceOptions): string | null;
export {};

@@ -11,8 +11,7 @@ "use strict";

*/
function useEventSource(url, options) {
function useEventSource(url, { event = "message", init } = {}) {
const [data, setData] = (0, react_1.useState)(null);
(0, react_1.useEffect)(() => {
var _a;
const eventSource = new EventSource(url, options === null || options === void 0 ? void 0 : options.init);
eventSource.addEventListener((_a = options === null || options === void 0 ? void 0 : options.event) !== null && _a !== void 0 ? _a : "message", handler);
const eventSource = new EventSource(url, init);
eventSource.addEventListener(event !== null && event !== void 0 ? event : "message", handler);
function handler(event) {

@@ -25,5 +24,5 @@ setData(event.data || "UNKNOWN_EVENT_DATA");

};
}, [url, options]);
}, [url, event, init]);
return data;
}
exports.useEventSource = useEventSource;
{
"name": "remix-utils",
"version": "4.2.0",
"version": "4.2.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "engines": {

@@ -1101,6 +1101,6 @@ # Remix Utils

const options = { event: "time" }
function Counter() {
let time = useEventSource("/sse/time", {
event: "time",
});
let time = useEventSource("/sse/time", options);

@@ -1107,0 +1107,0 @@ if (!time) return null;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc