Git Product home page Git Product logo

Comments (7)

Anthodpnt avatar Anthodpnt commented on June 30, 2024

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.

zhw2590582 avatar zhw2590582 commented on June 30, 2024

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.

zhw2590582 avatar zhw2590582 commented on June 30, 2024

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.

Anthodpnt avatar Anthodpnt commented on June 30, 2024

@zhw2590582 I'm not sure to understand why you need to fetch data when entering a page.

from highway.

zhw2590582 avatar zhw2590582 commented on June 30, 2024

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.

Anthodpnt avatar Anthodpnt commented on June 30, 2024

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.

zhw2590582 avatar zhw2590582 commented on June 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.