Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Pubnub.history #2

Merged
merged 2 commits into from Dec 15, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/examples/pubnub_chat.opa
Expand Up @@ -26,16 +26,15 @@ broadcast(author, msg) =
do PubNub.publish("chat", record_json) do PubNub.publish("chat", record_json)
Dom.clear_value(#entry) Dom.clear_value(#entry)


add_history(x: string) = add_history(history) =
match Json.deserialize(x) with LowLevelArray.iter(
| {some={List=history}} -> elt -> user_update_2(Json.deserialize(elt) ? {String = elt})
do List.iter(user_update_2, history) , history
void )
| _ -> void


launch(author) = launch(author) =
init_client() = 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))) PubNub.subscribe("chat", (x -> user_update(x)))
send_message() = send_message() =
broadcast(author, Dom.get_value(#entry)) broadcast(author, Dom.get_value(#entry))
Expand Down
5 changes: 4 additions & 1 deletion src/plugin/pubnub.js
@@ -1,4 +1,6 @@
// This is an Javascript file, containing opa preprocessing directives // This is an Javascript file, containing opa preprocessing directives
##extern-type llarray('a)
//' Declare llarray as an external type


##register publish : string, string -> void ##register publish : string, string -> void
##args(c, m) ##args(c, m)
Expand Down Expand Up @@ -29,7 +31,8 @@
return js_void; 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) ##args(channel, limit, callback)
{ {
PUBNUB.history({ PUBNUB.history({
Expand Down