Permalink
Browse files

Merge pull request #2 from BourgerieQuentin/master

Fixing Pubnub.history
  • Loading branch information...
2 parents 9157df8 + f0e6b7c commit 0f93c4d79487d2f372e4fcaf01b4e3756316cc18 @tsloughter committed Dec 15, 2011
Showing with 10 additions and 8 deletions.
  1. +6 −7 src/examples/pubnub_chat.opa
  2. +4 −1 src/plugin/pubnub.js
@@ -26,16 +26,15 @@ broadcast(author, msg) =
do PubNub.publish("chat", record_json)
Dom.clear_value(#entry)
-add_history(x: string) =
- match Json.deserialize(x) with
- | {some={List=history}} ->
- do List.iter(user_update_2, history)
- void
- | _ -> void
+add_history(history) =
+ LowLevelArray.iter(
+ elt -> user_update_2(Json.deserialize(elt) ? {String = elt})
+ , history
+ )
launch(author) =
init_client() =
- //do PubNub.history("chat", 20, (h -> add_history(h)))
+ do PubNub.history("chat", 20, (h -> add_history(h)))
PubNub.subscribe("chat", (x -> user_update(x)))
send_message() =
broadcast(author, Dom.get_value(#entry))
View
@@ -1,4 +1,6 @@
// This is an Javascript file, containing opa preprocessing directives
+##extern-type llarray('a)
+//' Declare llarray as an external type
##register publish : string, string -> void
##args(c, m)
@@ -29,7 +31,8 @@
return js_void;
}
-##register history : string, int, (string -> void) -> void
+// Callback history doesn't take a string as argument but a low level javascript array
+##register history : string, int, (llarray(string) -> void) -> void
##args(channel, limit, callback)
{
PUBNUB.history({

0 comments on commit 0f93c4d

Please sign in to comment.