aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-03-23 17:37:11 -0400
committerChloe Kudryavtsev <code@toast.bunkerlabs.net>2023-03-23 17:37:11 -0400
commiteae7f3e5dedc8b02cb8c59c0eee8bc0f1014955d (patch)
tree7d0c5ba80ce0bc17770828841f9d44f122c56895
parentnative: add OO-like setopt and getopt (diff)
janet: add example of get/put interface in init
-rw-r--r--jurl/init.janet5
1 files changed, 3 insertions, 2 deletions
diff --git a/jurl/init.janet b/jurl/init.janet
index a9dc959..d618814 100644
--- a/jurl/init.janet
+++ b/jurl/init.janet
@@ -26,12 +26,13 @@
# the latter being preferrable for anyone building their own wrapper
# it's intended for relatively low level use, but still usable directly
# the primary purpose is to allow options to be persisted
+# the main disadvantage is you can no longer use get for getinfo and put for setopt
(def Simple @{:type "JurlSimpleClient"
# make sure to set:
# :handle; output of native/new
# :options; optional, same as *default-options* but client-specific
- :getinfo |(:getinfo ($ :handle) $1)
+ :getinfo |(get ($ :handle) $1)
:perform (fn [$ &opt opts]
(when opts (apply-opts ($ :handle) opts))
(:perform ($ :handle))
@@ -42,7 +43,7 @@
$)
:setopt (fn [$ k v]
(put ($ :options) k v)
- (:setopt ($ :handle) k v)
+ (put ($ :handle) k v)
$)})
(defn new-simple