Skip to content

Commit

Permalink
feat: add idiomatic static function to help with type inference
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Prooks <aprooks@live.ru>
  • Loading branch information
aprooks committed Mar 3, 2017
1 parent 88a3498 commit e1cb885
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/FSharp.Example.Streams.Chat.Server/ChatUser.fs
Expand Up @@ -11,8 +11,9 @@ open FSharpx.Task
type ChatUser() =
inherit Actor<ChatUserMessage>()

let send (stream:StreamRef<ChatRoomMessage>) message userId =
stream.Push <| { UserName = userId; Text = message }
let send streamRef message userId =
{ UserName = userId; Text = message }
|> Stream.push streamRef

override this.Receive message = task {

Expand Down
7 changes: 7 additions & 0 deletions Source/Orleankka.FSharp/Api.fs
Expand Up @@ -16,6 +16,8 @@ type ActorRef<'TMsg>(ref:ActorRef) =

override this.GetHashCode() = ref.GetHashCode()



type StreamRef<'TMsg>(ref:StreamRef) =
member this.Path = ref.Path
member this.Push(item:'TMsg) = ref.Push(item) |> Task.awaitTask
Expand All @@ -29,6 +31,11 @@ type StreamRef<'TMsg>(ref:StreamRef) =

override this.GetHashCode() = ref.GetHashCode()


[<RequireQualifiedAccess>]
module Stream =
let push (ref:StreamRef<'TMsg>) (msg:'TMsg) = ref.Push(msg)


module ClientObservable =

Expand Down

0 comments on commit e1cb885

Please sign in to comment.