(let [opts (js/Object.)]
(set! (.-onSuccess opts) (fn [] (js/console.log "Successful Connect"))
(set! (.-onFailure opts) (fn [] (js/console.log "failure Connect"))
(.connect client opts))
Is what you want. You weren't setting those properties as your were in JS.
Honestly I'd probably write it more like this:
(.connect client
(js-obj
"onSuccess" (fn [] (js/console.log "Success!"))
"onFailure" (fn [] (js/console.log "Failure!"))))
or
(let [opts (js-obj
"onSuccess" (fn [] (js/console.log "Success!"))
"onFailure" (fn [] (js/console.log "Failure!")))]
(.connect client opts))
On Tue, Nov 20, 2012 at 11:49 AM, Thomas <[email protected]> wrote:
> At the moment I have this:
>
> (let [ client (js/Client. )
> connectOptions (new js/Object) ]
> (.onSuccess connectOptions ) (fn [] (js/console.log "Successful
> Connect"))
> (.onFailure connectOptions ) (fn [] (js/console.log "failure
> Connect")))
>
> If you need any more info please let me know.
>
> Thomas
>
> On Tuesday, November 20, 2012 4:07:12 PM UTC, David Nolen wrote:
>
>> What does your ClojureScript code look like?
>>
>>
>> On Tue, Nov 20, 2012 at 5:47 AM, Thomas <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> I am trying to use an existing JS library from CLJS and in JS one needs
>>> to define some call back functions in the following way. Assuming you have
>>> written some functions "foo" and "bar" and you have created a client called
>>> "client", you can do:
>>> var options = new Object();
>>> options.onSuccess = foo;
>>> options.onFailure = bar;
>>> client.connect(options);
>>>
>>> What would be the equivalent in CLJS? When I create a new Object I get
>>> the following error when I try and run the code:
>>>
>>> Uncaught TypeError: Object #<Object> has no method 'onSuccess'
>>>
>>> Which is of course not that surprising... But how to do this properly in
>>> CLJS?
>>>
>>> TIA
>>> Thomas
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to [email protected]
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@**googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>>>
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en