This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-25
Channels
- # announcements (9)
- # asami (69)
- # babashka (151)
- # babashka-sci-dev (34)
- # beginners (90)
- # cider (21)
- # clj-on-windows (17)
- # clj-otel (4)
- # cljsrn (5)
- # clojure (27)
- # clojure-austin (3)
- # clojure-europe (87)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-norway (8)
- # clojure-poland (2)
- # clojure-uk (3)
- # clojured (10)
- # clojurescript (50)
- # core-async (73)
- # cursive (28)
- # data-science (2)
- # datomic (17)
- # etaoin (1)
- # honeysql (6)
- # introduce-yourself (3)
- # jobs (1)
- # joyride (12)
- # malli (5)
- # nbb (14)
- # off-topic (18)
- # pathom (4)
- # podcasts-discuss (2)
- # polylith (30)
- # project-updates (3)
- # re-frame (33)
- # reitit (1)
- # remote-jobs (13)
- # shadow-cljs (59)
- # sql (12)
- # tools-build (7)
- # xtdb (36)
Looking at the REPL evaluation API of Calva here. I have it working. But there's a thing around how the promises resolve that I don't quite understand. Wonder if someone here might have some time to look at it with me so that I can get the docs right. Opening a huddle here a while and anyone can just join. 😃
Spoke too early about having it working. I can right now only get it to work if I am connected to the Joyride REPL. Very strange. But it is also super hard to keep track of which REPL is supposed to do what in this dance...
I have some promises experience. May find some time for huddling around 19:00 UTC if you still want to by then
That should work for me as well :-) you can ping me when you are available and Ill try to jump in
Thanks for that session, @U6JS7B99S! Super fun and very important feedback on the API.
@U0ETXRFEW I just took a peek again in the nrepl evaluation code (setHandler) - while for the reader its not directly obvious I don't see a possibility/case for it to go wrong, so its surely nothing to worry about.
Does this look right to you, @U6JS7B99S?
type Result = {
result: string;
ns: string;
output: string;
errorOutput: string;
};
export async function evaluateCode(
sessionKey: 'clj' | 'cljs',
code: string,
output?: {
stdout: (m: string) => void;
stderr: (m: string) => void;
}
): Promise<Result> {
const session = replSession.getSession(sessionKey);
if (!session) {
throw new Error(`Can't retrieve REPL session for session key: ${sessionKey}.`);
}
const stdout = output
? output.stdout
: (m: string) => {
state.outputChannel().append(m);
};
const stderr = output
? output.stdout
: (m: string) => {
state.outputChannel().append(`Error: ${m}`);
};
const evaluation = session.eval(code, undefined, {
stdout: stdout,
stderr: stderr,
pprintOptions: printer.disabledPrettyPrinter,
});
return {
result: await evaluation.value,
ns: evaluation.ns,
output: evaluation.outPut,
errorOutput: evaluation.errorOutput,
};
}