(λ. borkdude) on Nostr: A wild but perhaps too magic idea: coerce Atoms in squint into Promises such that you ...
A wild but perhaps too magic idea: coerce Atoms in squint into Promises such that you can still use cljs.core/deref on them, but also js-await.
Then we could compile @ to js-await in async contexts and we could write:
(let [resp @(js/fetch "
https://clojure.org";) txt @(.text resp)] txt)
etc, while preserving compatibility with atoms.
#clojure #squintcljs
Published at
2024-11-01 16:55:50Event JSON
{
"id": "c97fde87ac7c663e6a4c8fb19953c19bbf5f9a7113d42fd1f82cec9c2b5fdcb0",
"pubkey": "c4ef83416f079257f5390f7d55a65e684d1b498d196e0e71bb8b90e21a820e07",
"created_at": 1730480150,
"kind": 1,
"tags": [
[
"t",
"clojure"
],
[
"t",
"squintcljs"
],
[
"proxy",
"https://mastodon.social/users/borkdude/statuses/113408747119923259",
"activitypub"
]
],
"content": "A wild but perhaps too magic idea: coerce Atoms in squint into Promises such that you can still use cljs.core/deref on them, but also js-await.\nThen we could compile @ to js-await in async contexts and we could write:\n\n(let [resp @(js/fetch \"https://clojure.org\") txt @(.text resp)] txt)\n\netc, while preserving compatibility with atoms.\n\n#clojure #squintcljs",
"sig": "b79e3cdcde2c50c006cdd8ac44fe5d2d0e6dafc60d1e8d7139a332313a96664928cff762ca58fb5e6d5c438996d613fcb2fccb3c3b71d641e43d9c3308e5ca30"
}