-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from gabrieldavid98/feature/event-source-api-…
…support Add EventSource API support
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace rec Browser.Types | ||
|
||
open System | ||
open Fable.Core | ||
|
||
type EventSourceState = | ||
| CONNECTING = 0 | ||
| OPEN = 1 | ||
| CLOSED = 2 | ||
|
||
[<AllowNullLiteral; Global>] | ||
type EventSource = | ||
inherit EventTarget | ||
abstract readyState: EventSourceState | ||
abstract url: string | ||
abstract withCredentials: bool | ||
|
||
abstract close: unit -> unit | ||
|
||
abstract onerror: (Event -> unit) with get, set | ||
abstract onmessage: (MessageEvent -> unit) with get, set | ||
abstract onopen: (Event -> unit) with get, set | ||
|
||
[<Emit("$0.addEventListener('error',$1...)")>] | ||
abstract addEventListener_error: listener: (Event -> unit) * ?useCapture: bool -> unit | ||
|
||
[<Emit("$0.addEventListener('message',$1...)")>] | ||
abstract addEventListener_message: listener: (MessageEvent -> unit) * ?useCapture: bool -> unit | ||
|
||
[<Emit("$0.addEventListener('open',$1...)")>] | ||
abstract addEventListener_open: listener: (Event -> unit) * ?useCapture: bool -> unit | ||
|
||
[<AllowNullLiteral>] | ||
type EventSourceOptions = | ||
abstract withCredentials: bool with get, set | ||
|
||
[<AllowNullLiteral>] | ||
type EventSourceType = | ||
[<Emit("new $0($1...)")>] | ||
abstract Create: url: string * ?options: EventSourceOptions -> EventSource | ||
|
||
namespace Browser | ||
|
||
open Fable.Core | ||
open Browser.Types | ||
|
||
[<AutoOpen>] | ||
module EventSource = | ||
[<Global>] | ||
let EventSource: EventSourceType = jsNative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<PackageId>Fable.Browser.EventSource</PackageId> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<Tags>fable;fable-binding;fable-javascript</Tags> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="Browser.EventSource.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Fable.Core" Version="3.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Event\Browser.Event.fsproj" /> | ||
</ItemGroup> | ||
</Project> |