It does not really. This extra function wrapper is being called right in
place if you'll look closely:

var on_success = function(video, ___$2, active, completed, ___$1,
map__14064, map__14064__$1, q, map__14059, map__14059__$1, app, todos) {
              return function(stream) {
                return video["src"] = window.URL.createObjectURL(stream);
              };
            }(video, ___$2, active, completed, ___$1, map__14064,
map__14064__$1, q, map__14059, map__14059__$1, app, todos);

This happens because on_success is a closure over some variables, and to
make sure everything follows Clojure scoping rules rather than JS scoping
rules, this trick with self-calling function is used.

On Mon, Sep 8, 2014 at 1:55 AM, Bobby Harris <[email protected]> wrote:

> I'm having a promblem using GetUserMedia from clojurescript.
>
> My clojurescript loks like:
>
>  (let  [video (.getElementById js/document "video")
>                _ (js/alert video)
>                success (fn [stream] (aset video "src" (.createObjectURL
> (.-URL js/window) stream)))
>                error (fn [err] (. js/console (log (str "error: ") err)))
>                params #js {:audio true :video true}]
>             (.webkitGetUserMedia js/navigator params success error)))
>
>
> and the javascript:
>
> var video = document.getElementById("video");
>             var ___$2 = alert(video);
>             var on_success = function(video, ___$2, active, completed,
> ___$1, map__14064, map__14064__$1, q, map__14059, map__14059__$1, app,
> todos) {
>               return function(stream) {
>                 return video["src"] = window.URL.createObjectURL(stream);
>               };
>             }(video, ___$2, active, completed, ___$1, map__14064,
> map__14064__$1, q, map__14059, map__14059__$1, app, todos);
>             var on_error = function(video, ___$2, on_success, active,
> completed, ___$1, map__14064, map__14064__$1, q, map__14059,
> map__14059__$1, app, todos) {
>               return function(err) {
>                 return console.log([cljs.core.str("navigator.getUserMedia
> error: ")].join(""), err);
>               };
>             }(video, ___$2, on_success, active, completed, ___$1,
> map__14064, map__14064__$1, q, map__14059, map__14059__$1, app, todos);
>             var constraints = {"video":true, "audio":false};
>             return navigator.webkitGetUserMedia(constraints, on_success,
> on_error);
>           };
>
> There seems to be an extra function wrapper (with a mysterious interface)
> around the success method.
>
> Thanks in advance.
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to