This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns frontend.api.core | |
(:require [ajax.core :as ajax] | |
[cljs.core.async :refer [chan put! close!]] | |
[frontend.async.core :refer [channel-error]])) | |
(defn <?GET [url] | |
"Async. Returns a maybe-channel." | |
(let [<?chan (chan)] | |
(ajax/GET url | |
{:handler #(do (put! <?chan %) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Synchronous Clojure trained us to use Exceptions, while asynchronous JavaScript has trained us to use Promises. | |
;; In contexts where we work asynchronously in Clojure (in particular ClojureScript), it can be difficult to see a definite way of managing failure. Here are some proposals. | |
;; OPTION 1: adapting exception handling to core.async CSPs | |
;; As proposed by David Nolen, with some macro sugar we use Exceptions in go blocks with core async in the same way we would do with synchronous code. | |
(require '[clojure.core.async :as a :refer [go]]) | |
;; defining some helper macros | |
(defn throw-err "Throw if is error, will be different in ClojureScript" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -sp-context:browser | |
// Open this file in scratchpad and run it. Output goes to the Browser Console (Cmd-Shift-J). | |
Components.utils.import("resource://gre/modules/devtools/dbg-server.jsm"); | |
Components.utils.import("resource://gre/modules/devtools/dbg-client.jsm"); | |
let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); | |
let { StyleSheetsFront } = devtools.require("devtools/server/actors/stylesheets"); | |
let client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require parser-tools/lex | |
(prefix-in re- parser-tools/lex-sre) | |
parser-tools/yacc) | |
(provide (all-defined-out)) | |
(define-tokens a (NUM VAR)) | |
(define-empty-tokens b (+ - EOF LET IN)) | |
(define-lex-trans number | |
(syntax-rules () |