You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After see #6175, I want to implement my own solution. However, what I thought would be a fun side project turned into frustration. My plan was to simply transform the URL path into hash at the browser end so we can reuse everything else of the current routing system.
First, I tried extending Router. Nope most of the things are internal or private and there is not even a way to wrap it due to all the injection. Wrapping: not possible, copying the whole code: not possible due to multiple internal classes as well.
Then I tried a "nuclear" option by replacing Javascript globalThis.location (href) and globalThis.history (for pushState and replaceState). I failed because location cannot be modified in any way: Proxy, defineProperty or even straight up replacing the window object (strangely enough it wasn't a problem with history). Then I go to a milder option of replacing Blazor._internal.navigationManager but still wasn't successful because beside the obvious functions (that barely even called), a few of them can't be modified at all.
So, IMO, for something as important as Routing, it's so hard to intercept and customize. I had a similar frustration before when trying to modify the IJSRuntime object (though in the end I barely made it through by modifying the whole DI thing and wrap it). I wish they either open up more point of customization or stop hiding so many important classes.
What do you think? Do you have any suggestion where I may be able to continue with this? Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
After see #6175, I want to implement my own solution. However, what I thought would be a fun side project turned into frustration. My plan was to simply transform the URL path into hash at the browser end so we can reuse everything else of the current routing system.
Router
. Nope most of the things areinternal
orprivate
and there is not even a way to wrap it due to all the injection. Wrapping: not possible, copying the whole code: not possible due to multipleinternal
classes as well.globalThis.location
(href
) andglobalThis.history
(forpushState
andreplaceState
). I failed becauselocation
cannot be modified in any way:Proxy
,defineProperty
or even straight up replacing thewindow
object (strangely enough it wasn't a problem withhistory
). Then I go to a milder option of replacingBlazor._internal.navigationManager
but still wasn't successful because beside the obvious functions (that barely even called), a few of them can't be modified at all.So, IMO, for something as important as Routing, it's so hard to intercept and customize. I had a similar frustration before when trying to modify the
IJSRuntime
object (though in the end I barely made it through by modifying the whole DI thing and wrap it). I wish they either open up more point of customization or stop hiding so many important classes.What do you think? Do you have any suggestion where I may be able to continue with this? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions