Fork me on GitHub
#hyperfiddle
<
2018-08-16
>
miridius06:08:26

hi @dustingetz I liked what you said about fiddle structure should model the API -- seems like I was trying to use hyperfiddle as kind of a full front end framework which I guess is not the intention (yet?). So what would make more sense is to use it as the DB layer and the API layer, as well as for testing/visualising/prototyping the API with fiddles, and for all the "admin" pages for administering data and so on which are not visible to the public and don't need to be fancy. And then a separate, "fancy", end user client web app can be built in front of that, which calls the API when it needs data. What do you think? Is there anywhere that I can see how to use the API externally? Or should I just have a look at the network tab of developer tools and figure it out that way?

Dustin Getz11:08:02

@miridius The "fancy" version can be done hyperfiddle for quite a while (through the MVP stage, at least). I would just tone it down a little – don't make fiddles that hold only a clojurescript function. An common idiom is: `(let [{:keys [:hypercrud.browser/data]} @(hyperfiddle.data/browse+ ctx :iframe "account")] [:pre (pr-str @data)])`

miridius12:08:42

I don't really get what that code is doing - does hyperfiddle.data/browse+ make an API call?

Dustin Getz12:08:55

@miridius Since it's an iframe the data is already on the page (e.g. toggle API view to confirm this). hyperfiddle.data/browse+ is symmetrical with hyperfiddle.ui/browse, except instead of rendering the child fiddle, it just returns the ctx/data directly, for the parent to render

Dustin Getz12:08:30

:iframe is a link/rel and "account" is a link/class

miridius12:08:30

@dustingetz can I delete fiddles?

Dustin Getz12:08:47

@miridus Yes but the remove fiddle button is broken today 🙂

miridius12:08:42

I'll just rename them to something like :deleteme/<name> in the interim

Dustin Getz12:08:02

You can stage [:db/retractEntity :fiddleident] directly

khardenstine15:08:19

[:db/retractEntity [:fiddle/ident :your-fiddle-ident]]

Dustin Getz12:08:22

Refresh, i added more

Dustin Getz12:08:56

Does this help answer your questions, or am I missing the point?

miridius13:08:57

ok yeah that's pretty awesome if I'm building everything in hyperfiddle. But my question was around how can I call the APIs externally? Or are you saying that the best way to do that would be to use the hyperfiddle jar in my external program?

Dustin Getz13:08:17

To do that today you'd compile against hyperfiddle.jar, adding a deploy cycle etc

Dustin Getz13:08:42

You could of course hit the API directly, but now you have to write network code, async and error handling etc

miridius13:08:28

yeah much easier to use the jar