Code Monkey home page Code Monkey logo

Comments (6)

zhoushaw avatar zhoushaw commented on May 25, 2024

I would like to know why someone would want to set the entry as a function. If it's simply to make the entry dynamic, it can be converted in the beforeRegisterApp hook so that any necessary parameters can be processed. If we implement it internally, we may execute the entry function directly during registerApp and then register the entry as a string. This should be consistent with how the beforeRegisterApp hook handles it, but it may cause confusion because the user doesn't know when the entry will be executed.

from garfish.

yiminghe avatar yiminghe commented on May 25, 2024

I would like to know why someone would want to set the entry as a function. If it's simply to make the entry dynamic, it can be converted in the beforeRegisterApp hook so that any necessary parameters can be processed. If we implement it internally, we may execute the entry function directly during registerApp and then register the entry as a string. This should be consistent with how the beforeRegisterApp hook handles it, but it may cause confusion because the user doesn't know when the entry will be executed.

entry should change when history change, not just registerApp. see above nextjs example

from garfish.

zhoushaw avatar zhoushaw commented on May 25, 2024

I see, but for this case, I think it can be placed in the beforeLoad hook, as it involves the behavior of location change. Also, we now cache resources, and if it's dynamic, it may involve cache invalidation. I'm wondering if you can customize an additional parameter to dynamically determine whether appInfo can be recalculated. For example:

Garfish.run({
 apps: [
   {
      name: 'vue',
      entry: '',
      entryFn: ()=> 'xxx',
   }
 ],
 beforeLoad(appInfo){
   if (appInfo.entryFn) {
     appInfo.entry = appInfo.entryFn()
   }
 }
})

from garfish.

yiminghe avatar yiminghe commented on May 25, 2024

I see, but for this case, I think it can be placed in the beforeLoad hook, as it involves the behavior of location change. Also, we now cache resources, and if it's dynamic, it may involve cache invalidation. I'm wondering if you can customize an additional parameter to dynamically determine whether appInfo can be recalculated. For example:

Garfish.run({
 apps: [
   {
      name: 'vue',
      entry: '',
      entryFn: ()=> 'xxx',
   }
 ],
 beforeLoad(appInfo){
   if (appInfo.entryFn) {
     appInfo.entry = appInfo.entryFn()
   }
 }
})

截屏2023-04-04 12 31 37

from garfish.

zhoushaw avatar zhoushaw commented on May 25, 2024

Sorry, forgot to reply. In response to this problem, I suggest to treat it as a different appInstan, because now each entry is unique, and if the same entry is changed, it is actually equivalent to a different application. We are not very good at handling appInstance. Support does not support dynamic entry, which will cause damage to our cache instance

from garfish.

yiminghe avatar yiminghe commented on May 25, 2024

Sorry, forgot to reply. In response to this problem, I suggest to treat it as a different appInstan, because now each entry is unique, and if the same entry is changed, it is actually equivalent to a different application. We are not very good at handling appInstance. Support does not support dynamic entry, which will cause damage to our cache instance

Current solution using beforeLoad and cache false almost works, dynamic entry is not required

from garfish.

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.