Best pattern to fetch data based on a path
See original GitHub issueExpected behavior
var html = require('choo/html')
var choo = require('choo')
var app = choo()
app.use(productStore)
app.route('/product/:id', mainView)
app.mount('body')
function mainView (state, emit) {
return html` <body onload=${pullData}>
<h1>product is ${state.product.name}</h1>
</body>
`
function pullData(){
emitter.emit('fetchProduct');
}
}
function productStore (state, emitter) {
emitter.on('fetchProduct', function () {
fetch('/product/'+state.params.id,function (product) {
state.product = product;
emitter.emit('render')
})
})
}
I was wondering if this is a good pattern in order to fetch some data when access some URL.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Which design pattern suitable to fetch same type of data from ...
Which design pattern suitable to fetch same type of data from multiple sources, club them into a single unit and applying multiple filters....
Read more >A comprehensive guide to data fetching in React
We explore common data fetching strategies in React, paired with examples and alternatives. See which approach is best for your next ...
Read more >Common big data design patterns | Packt Hub
This article covers big data design patterns based on various data layers such as data sources and ingestion layer, data storage layer etc....
Read more >NextJS / React SSR: 21 Universal Data Fetching Patterns ...
21 Universal Data Fetching Patterns & Best Practices for NextJS / React SSR.
Read more >When to Use Different Data-Fetching Methods in Next.js
One of the reasons why Next.js has become such a popular framework for building React-based websites is that it provides so many different ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a very common issue ! Do you really use Choo in your real project ? @yoshuawuyts
Forgive my rudeness, but the routing system in Choo really sucks !I’m very rude, and the routing system in Choo really sucks !@chuck911 - You’re being very hurtful by saying an open source library that has taken 100s of hours of people’s free time sucks. What’s more is you haven’t suggested anything constructive that solves the issue at hand.
Please take a moment before posting comments that purposefully upset people who are passionate contributors to open source.