@vaadin/hilla-frontend
Advanced tools
Comparing version 24.6.0-alpha2 to 24.6.0-alpha3
@@ -58,2 +58,3 @@ import type { Subscription } from './Connect.js'; | ||
state: State; | ||
wasClosed: boolean; | ||
constructor(connectPrefix: string, atmosphereOptions?: Partial<Atmosphere.Request>); | ||
@@ -60,0 +61,0 @@ /** |
@@ -25,2 +25,3 @@ import atmosphere from "atmosphere.js"; | ||
state = "inactive" /* INACTIVE */; | ||
wasClosed = false; | ||
#endpointInfos = /* @__PURE__ */ new Map(); | ||
@@ -39,2 +40,23 @@ #nextId = 0; | ||
} | ||
#resubscribeIfWasClosed() { | ||
if (this.wasClosed) { | ||
this.wasClosed = false; | ||
const toBeRemoved = []; | ||
this.#endpointInfos.forEach((endpointInfo, id) => { | ||
if (endpointInfo.reconnect?.() === "resubscribe" /* RESUBSCRIBE */) { | ||
this.#setSubscriptionConnState(id, "connecting" /* CONNECTING */); | ||
this.#send({ | ||
"@type": "subscribe", | ||
endpointName: endpointInfo.endpointName, | ||
id, | ||
methodName: endpointInfo.methodName, | ||
params: endpointInfo.params | ||
}); | ||
} else { | ||
toBeRemoved.push(id); | ||
} | ||
}); | ||
toBeRemoved.forEach((id) => this.#removeSubscription(id)); | ||
} | ||
} | ||
/** | ||
@@ -119,2 +141,3 @@ * Subscribes to the flux returned by the given endpoint name + method name using the given parameters. | ||
onClose: () => { | ||
this.wasClosed = true; | ||
if (this.state !== "inactive" /* INACTIVE */) { | ||
@@ -140,2 +163,3 @@ this.state = "inactive" /* INACTIVE */; | ||
if (this.state !== "active" /* ACTIVE */) { | ||
this.#resubscribeIfWasClosed(); | ||
this.state = "active" /* ACTIVE */; | ||
@@ -148,17 +172,3 @@ this.dispatchEvent(new CustomEvent("state-changed", { detail: { active: true } })); | ||
if (this.state !== "active" /* ACTIVE */) { | ||
const toBeRemoved = []; | ||
this.#endpointInfos.forEach((endpointInfo, id) => { | ||
if (endpointInfo.reconnect?.() === "resubscribe" /* RESUBSCRIBE */) { | ||
this.#send({ | ||
"@type": "subscribe", | ||
endpointName: endpointInfo.endpointName, | ||
id, | ||
methodName: endpointInfo.methodName, | ||
params: endpointInfo.params | ||
}); | ||
} else { | ||
toBeRemoved.push(id); | ||
} | ||
}); | ||
toBeRemoved.forEach((id) => this.#removeSubscription(id)); | ||
this.#resubscribeIfWasClosed(); | ||
this.state = "active" /* ACTIVE */; | ||
@@ -172,8 +182,4 @@ this.dispatchEvent(new CustomEvent("state-changed", { detail: { active: true } })); | ||
this.state = "reconnecting" /* RECONNECTING */; | ||
this.#endpointInfos.forEach((endpointInfo, id) => { | ||
if (endpointInfo.reconnect?.() === "resubscribe" /* RESUBSCRIBE */) { | ||
this.#setSubscriptionConnState(id, "connecting" /* CONNECTING */); | ||
} else { | ||
this.#setSubscriptionConnState(id, "closed" /* CLOSED */); | ||
} | ||
this.#endpointInfos.forEach((_, id) => { | ||
this.#setSubscriptionConnState(id, "connecting" /* CONNECTING */); | ||
}); | ||
@@ -180,0 +186,0 @@ } |
@@ -5,3 +5,3 @@ function __REGISTER__(feature, vaadinObj = window.Vaadin ??= {}) { | ||
is: feature ? `${"@vaadin/hilla-frontend"}/${feature}` : "@vaadin/hilla-frontend", | ||
version: "24.6.0-alpha2" | ||
version: "24.6.0-alpha3" | ||
}); | ||
@@ -8,0 +8,0 @@ } |
{ | ||
"name": "@vaadin/hilla-frontend", | ||
"version": "24.6.0-alpha2", | ||
"version": "24.6.0-alpha3", | ||
"description": "Hilla core frontend utils", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
125002
1280