()
| 257 | |
| 258 | _textEffect: Effect.Effect<string, E> | undefined |
| 259 | get text(): Effect.Effect<string, E> { |
| 260 | if (this._textEffect) { |
| 261 | return this._textEffect |
| 262 | } |
| 263 | return this._textEffect = Effect.callback<string, E>((resume) => { |
| 264 | if (this.source.readyState === 4) { |
| 265 | resume(Effect.succeed(this.source.responseText)) |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | const onReadyStateChange = () => { |
| 270 | if (this.source.readyState === 4) { |
| 271 | resume(Effect.succeed(this.source.responseText)) |
| 272 | } |
| 273 | } |
| 274 | const onError = () => { |
| 275 | resume(Effect.fail(this.onError(this.source.statusText))) |
| 276 | } |
| 277 | this.source.addEventListener("readystatechange", onReadyStateChange) |
| 278 | this.source.addEventListener("error", onError) |
| 279 | return Effect.sync(() => { |
| 280 | this.source.removeEventListener("readystatechange", onReadyStateChange) |
| 281 | this.source.removeEventListener("error", onError) |
| 282 | }) |
| 283 | }).pipe( |
| 284 | Effect.cached, |
| 285 | Effect.runSync |
| 286 | ) |
| 287 | } |
| 288 | |
| 289 | get json(): Effect.Effect<Schema.Json, E> { |
| 290 | return Effect.flatMap(this.text, (text) => |
nothing calls this directly
no test coverage detected