type TrendsAvailable = obj
Full name: index.TrendsAvailable
type TrendsPlace = obj
Full name: index.TrendsPlace
type TrendsClosest = obj
Full name: index.TrendsClosest
Multiple items
type Trends =
new : context:obj -> Trends
member Available : unit -> string * 'a list
Full name: index.Trends
--------------------
new : context:obj -> Trends
val context : obj
val t : Trends
member Trends.Available : unit -> string * 'a list
Full name: index.Trends.Available
val res : 'a
module Observable
from Microsoft.FSharp.Control
val event : Event<obj>
Multiple items
module Event
from Microsoft.FSharp.Control
--------------------
type Event<'T> =
new : unit -> Event<'T>
member Trigger : arg:'T -> unit
member Publish : IEvent<'T>
Full name: Microsoft.FSharp.Control.Event<_>
--------------------
type Event<'Delegate,'Args (requires delegate and 'Delegate :> Delegate)> =
new : unit -> Event<'Delegate,'Args>
member Trigger : sender:obj * args:'Args -> unit
member Publish : IEvent<'Delegate,'Args>
Full name: Microsoft.FSharp.Control.Event<_,_>
--------------------
new : unit -> Event<'T>
--------------------
new : unit -> Event<'Delegate,'Args>
val agent : MailboxProcessor<obj>
Multiple items
type MailboxProcessor<'Msg> =
interface IDisposable
new : body:(MailboxProcessor<'Msg> -> Async<unit>) * ?cancellationToken:CancellationToken -> MailboxProcessor<'Msg>
member Post : message:'Msg -> unit
member PostAndAsyncReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout:int -> Async<'Reply>
member PostAndReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout:int -> 'Reply
member PostAndTryAsyncReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout:int -> Async<'Reply option>
member Receive : ?timeout:int -> Async<'Msg>
member Scan : scanner:('Msg -> Async<'T> option) * ?timeout:int -> Async<'T>
member Start : unit -> unit
member TryPostAndReply : buildMessage:(AsyncReplyChannel<'Reply> -> 'Msg) * ?timeout:int -> 'Reply option
...
Full name: Microsoft.FSharp.Control.MailboxProcessor<_>
--------------------
new : body:(MailboxProcessor<'Msg> -> Async<unit>) * ?cancellationToken:System.Threading.CancellationToken -> MailboxProcessor<'Msg>
static member MailboxProcessor.Start : body:(MailboxProcessor<'Msg> -> Async<unit>) * ?cancellationToken:System.Threading.CancellationToken -> MailboxProcessor<'Msg>
val inbox : MailboxProcessor<obj>
val loop : ('b -> Async<'c>)
val lastTime : 'b
val async : AsyncBuilder
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.async
val e : obj
member MailboxProcessor.Receive : ?timeout:int -> Async<'Msg>
val now : 'b
member Event.Trigger : arg:'T -> unit
What am I doing here?
DEMO
Listening to Tweets
Adding Trends API
1:
2:
3:
|
type TrendsAvailable = JsonProvider<"json/trends_available.json">
type TrendsPlace = JsonProvider<"json/trends_place.json">
type TrendsClosest = JsonProvider<"json/trends_closest.json">
|
1:
2:
3:
4:
5:
|
type Trends (context:TwitterContext) =
member t.Available () =
let res = TwitterRequest(context).RequestRawData
("https://api.twitter.com/1.1/trends/available.json", [])
TwitterTypes.TrendsAvailable.Parse(res)
|
DEMO
Processing Tweets
Implementing Reactive Extensions
1:
2:
|
liveTweets
|> Observable.limitRate 50
|
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
|
let event = Event<'T>()
let agent = MailboxProcessor.Start(fun inbox ->
let rec loop (lastTime:DateTime) = async {
let! e = inbox.Receive()
let now = DateTime.UtcNow
if (now - lastTime).TotalMilliseconds > milliseconds then
event.Trigger(e)
return! loop now
else
return! loop lastMessageTime }
loop DateTime.MinValue )
|
DEMO
Geolocating Users
Celebrating New Year's Evewith F# and Suave
Tomas Petricek
@tomaspetricek | fsharpworks.com