python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.29k stars 582 forks source link

Angular Route/URL error after refresh #655

Closed shidandev closed 1 year ago

shidandev commented 1 year ago

Can you help how to overcome virtual route for angular compatible with eel after refresh, hosting i use .htaccess but in this i have no clue to proceed

shidandev commented 1 year ago

i found solution, use this reference, ~but python eel can't invoke function from js eel, from my understanding, python init -> my directory and start without detecting eel.expose in every component in angular, except eel.expose in index.html~

workaround for python pass data to angular: https://github.com/python-eel/Eel/issues/655#issuecomment-1554179655

nricciardi commented 1 year ago

Very good, I report here briefly the solutions reported in the references in case they are no longer available in the future:

You should can close issue now.

shidandev commented 1 year ago

Update for Angular, python eel can invoke simple function put on index.html

step 1. app.component.ts,

window["dummy"] = new Subject() //<=== Subject come from rxjs window["dummy"].subscribe((res) => { //do anything you want from data subscribe console.log(res); // {"msg":"something from python"} })

step 2. index.html

eel.expose(sendData); function sendData(data){ if(data){ window["dummy"].next(data); //<== window["dummy"] created as Subject Instance from rxjs } }

!!! make sure key "dummy" created on window object as Subject Instance...

then on python, just call function declare on index.html....

eel.sendData({"msg":"something from python"})

try to make angular service listen to window["dummy"] based on your system requirement.... or make it dynamic...