Fork me on GitHub
#biff
<
2023-08-27
>
Jacob O'Bryant14:08:09

can someone with an iPhone check if they run into this problem on https://biffweb.com on mobile safari? https://github.com/jacobobryant/biff/issues/165 looks like there's a z-index issue from the screenshot, though it works for me on mobile Firefox and Chrome.

timur15:08:44

Can confirm

timur04:08:49

Confirm the fix 👍

🎅 2
vonadz16:08:49

Is there a way to get config vars (from config.edn) on the back-end on startup (so not from the ctx object in handlers)? Or do I need to add something like aero? Use case is to set up the aws api

vonadz17:08:31

Or I guess I can just use use-config with an empty map and define a config var in the file.

vonadz17:08:06

Although it seems doing that, the :merge [:prod] functionaltiy doesn't work.

Epidiah Ravachol18:08:14

This might help! You probably have a repl.clj file that has a function called something like get-sys or get-context (I think my version is a bit out of date, so I'm not sure what it's called these days.) That'll summon up all the config stuff without going through any handlers. It's basically just calling biff/assoc-db on the system atom from your main file. That system atom might be what you want, but if you're going to do anything with the database, the assoc-db makes sure you're working with the most recent version of it.

Jacob O'Bryant18:08:23

no need to use get-context; that's just meant for repl usage. I'm pretty sure what you'll want to do is create a "biff component" function, like use-aws, and stick it in your app's component list somewhere after the use-config component. the contents of your config are merged into the map that gets passed to all the component functions. so you can do something like this:

(defn use-aws [ctx]
  (let [access-key (get ctx :aws/access-key)]
    ...
    ctx)

1
👍 1
vonadz18:08:27

thanks for the replies! Yeah @U7YNGKDHA I think I'll do this since it seems more consistent with the design of biff in general. What are the advantages of this componentized approach?

Jacob O'Bryant19:08:23

the biggest reason I went with this is because it means you can easily move components between app code and library code without making changes. I.e. all the biff/use-* components are just regular functions that operate on only their input arguments; they don't depend on any global vars, which is necessary since they're kept in library code. even for your own custom components that you have no plans of moving into a separate library, I think it still makes sense to stick with "pure"-ish components for a few reasons: • it's consistent with the design of biff's default components ¯\_(ツ)_/¯ • when you're debugging something, you know the entire "world" is contained within the context map; no need to think about any global vars • it's easy to create mock/alternate versions of stuff for E.g. testing. just pass in whatever you want, no need to rebind global vars or anything. • another one I just thought of that might be the most important: it keeps your functions' dependencies more explicit. if a function needs access to the system map/stateful resources, you have to pass those things to the function explicitly. you won't get any surprise "utility" functions that are secretly making database calls.

❤️ 1
vonadz20:08:52

thanks for the breakdown 🙂

👌 1
Martynas Maciulevičius20:08:01

What is a way to create xtdb so that I could use without any persistence? I want fully in-RAM instance. I tried this but it wants to read files on local filesystem:

(def xt-node-biff (biff/start-node {:topology :standalone}))
The default XTDB allows to do this for fully in-mem mode:
(def xt-node (xt/start-node {}))
I think that :standalone and :jdbc configurations don't allow to run fully in-mem. I might be wrong. Or does it mean that I should use XTDB's default way of creation?

Jacob O'Bryant21:08:54

yeah, you can just call xt/start-node directly. biff/start-node is just meant to make a couple cases (filesystem storage and jdbc storage) more convenient.

2