fluorjs / fluor

Sprinkle interactivity on your design
https://fluorjs.github.io/
223 stars 6 forks source link

Add proper fetching feature #18

Closed evgeniyPP closed 4 years ago

evgeniyPP commented 4 years ago

I figured out one way how to fetch data using Flour.js

<script type="fluor">
    setup("todos", []);
    (async () => {
        setup("todos", await fetchTodos());
        render();
    })()
</script>

where fetchTodos() is

async function fetchTodos() {
    const response = await fetch('https://jsonplaceholder.typicode.com/todos');
    const data = await response.json();
    return data.slice(0, 10);
}

It is very uncomfortable. Is it possible to make any functionality specifically for this?

madx commented 4 years ago

I'm still considering wether I want to add XHR/fetch utilities to Fluor. Since there's already htmx maybe it would be too much.

I'll leave this issue open until I decide what to do.

evgeniyPP commented 4 years ago

If you decide that it would be too much, you definitely should leave a recommendation in the docs on how you advise doing it (htmx, etc.). For example, I have not heard about htmx and tried to solve the problem with existing resources.

madx commented 4 years ago

Sure thing, I'd have to look for what exists to do this :)

madx commented 4 years ago

So, I won't add XHR/fetching related methods as it is not in the scope of the library. I just want it to focus on DOM interaction. You can use async functions as event handlers and use fetch, or use another solution like HTMX.