Comments (7)
Hi @zhw2590582,
I think this could be a good idea, can you just be more specific and describe a use case scenario ?
Thanks,
Anthodpnt
from highway.
Just sometimes, every time I enter the view, I don't want to re-ajax to modify the dom. I just want to ajax once and cache the result.
common.js
import Highway from "@dogstudio/highway/build/es5/highway";
export default new Highway.Core({
renderers: {
index: () => import(/* webpackChunkName: "index" */ "./index")
}
});
index.js
import H from "./common";
export default class Renderer extends Highway.Renderer {
onEnter() {
console.log("onEnter");
}
}
// Request data once
fetchData().then(data => {
// modify the dom something...
// then update the cache
H.updateCache();
});
from highway.
In my project, I don't think this is a good habit. Like:
export default class Renderer extends Highway.Renderer {
// Request data every time
onEnter() {
fetchData().then(data => {
// modify the dom every time...
});
}
}
from highway.
@zhw2590582 I'm not sure to understand why you need to fetch data when entering a page.
from highway.
Going to the page and then fetch data just a very common requirement. It's like getting the remote list data and rendering the table dom or something. But the remote list data doesn't change often, I don't want to request data every time I enter the page. This is just my personal advice...😄
from highway.
Ok so for example you come on a page, fetch datas from an API for example to display a list or something and you want to update the cache of Highway manually. But why don't you just check if the page is in cache and fetch the datas only if it's not instead of updating the cache ?
from highway.
Because Highway is just caching the dom before ajax, not the dom after ajax, I think I can handle this problem., thank you for your reply, I can close this issue now. 😄
from highway.
Related Issues (20)
- Javascript functions doesn't works on the second time HOT 1
- Locomotive scroll not updating after page transition HOT 3
- I can't get the HIGHWAY.redirect() to work HOT 1
- Updating CSS for incoming page – (Highway maintains the outgoing page's CSS) HOT 5
- data-transition attribute no longer works in 2.2.2 HOT 2
- Update /refresh/bind links dynamically created with javascript HOT 1
- New href with highway HOT 13
- Adding additional headers to page requests
- Add index.d.ts file for better IDE typehinting
- back/forward buttons pressed during transition break the website
- Facebook Pixel Tracking HOT 3
- Fatal error on transition to mismatching URL scheme, while remaining on the same domain
- Can't work with CDN
- Improper use of DOM events
- Highway not working with DOM elements rendered by javascript HOT 1
- H.redirect always refresh page HOT 1
- Help
- H is undefined HOT 1
- Navigation with parameters and anchor not working
- Javascript not working after page transition HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highway.