Giter Club home page Giter Club logo

electron-router's People

Contributors

dependabot[bot] avatar geblanco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

electron-router's Issues

angular 2

Electron-router how to use in the angular 2๏ผŸ
thanks

Can not do redirect

Hi all. In my main.js I have defined routes look like this

router.on('ready', () => {
        router.on('quit', () => {
        });
        router.on('register', (req, res) => {
            showTemplate(APP.Templates.Register);
        });
        router.on('login', (req, res) => {
            showTemplate(APP.Templates.Login);
        });
        router.on('logout', (req, res) => {
            storage.delete(API.UserIDKey);
            storage.delete(API.UserTokenKey);
            API_USER = {};
            router.send('login');
        });
        router.on('dashboard', (req, res) => {
            console.log(1);
            showTemplate(APP.Templates.Dashboard)
        });
        router.on('accounts', (req, res) => {
            getDashboard();
        });
    });

Than I am checking ,if the user has logined than redirect to the dashboard route

if (typeof API_USER.token !== 'undefined' && typeof API_USER.id !== 'undefined') {
        router.send('dashboard');
    } 

But the route sending is not working. Please help!

Can not use a tag

Hi. In my app I have a code look like this

const electron = require('electron')
var url = require('url')
var path = require('path');

const Router = require('electron-router')

let router = Router()

const {app, BrowserWindow, Menu} = electron

var mainWindow = null;


app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('ready', function () {
    mainWindow = new BrowserWindow({});

    mainWindow.loadURL(url.format({
        pathname: path.join(__dirname, '/templates/login.html'),
        protocol: 'file:',
        slashes: true
    }));

    mainWindow.on('closed', function () {
        mainWindow = null;
    });

    const mainManu = Menu.buildFromTemplate([])
    Menu.setApplicationMenu(mainManu)

    router.on('ready', () => {
        console.log(11212)
        router.on('quit', () => {
        })
    })
});

router.get('registration', (req, res) => {
    console.log(1111)
})

And in my login.html I have a a tag
<a href="registration" class="nav-link">Registration</a>

So after clicking on a console.log(), also now torking ready event of router

Error: Timeout - 200ms elapsed at eval

hi fiends !!
I got this error when I used axios with the electron in Main Process to fetch data from electron .

Error: Timeout - 200ms elapsed at eval

jest testing - router cannot be created

first of all thanks for the great module. I am using it in a multi-threaded (multi-window, but only the main window is visible) application which gathers information from various channels (IP, CAN-bus, etc.) and displays it in the UI.

When I test an object (using jest) which creates a router, Router(name) fails with the following error:

  at Router._isRenderProcess (node_modules/electron-router/router.js:153:20)
  at Router._setup (node_modules/electron-router/router.js:117:18)
  at Router (node_modules/electron-router/router.js:110:12)
  at node_modules/electron-router/router.js:440:17
  at new ChangeHandler (src/common/changeHandler.ts:22:20)
  at Object.it (__tests__/changeHandler.test.js:21:20)

it seems you access the remote object, which is not available in the JEST environment (since electron is not running). is there a way around this?

Cannot read property 'hasOwnProperty' of undefined"

Hi,
thanks for project
Today, i have a error :

"Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined", source: D:\Dropbox\Skyhotel_Int_Apps\electron_tong_dai_tulip123\electron\node_modules\electron-router\router.js (168)

and at line router.js (168)

return remote.hasOwnProperty('getCurrentWindow')

Can you fix this error ?

Feature Request: Template rendering

Hi, very good module !
Can you please when you planed Template rendering (i.e.: res.render(data)) ?
Thank you in advance.
Best Regards, Julien

Documentation - simple complete example

Need a simple complete working example.
This routing library is tiny, and seems promising,
The documentation also seems to be good, however, one thing missing is a simple but complete working example. Without that, I'm afraid to send a few hours trying to get this to work by trial and error.

Error thrown during cleanup

If a window is closed, Router.prototype.clean is run in response to the window's close event:
https://github.com/m0n0l0c0/electron-router/blob/db1f1fa487bc98552eaa47a18e562fd4e92cc365/router.js#L116-L123

However, this.clean is not bound to this, so trying to access members of the _name property will fail with a TypeError:
https://github.com/m0n0l0c0/electron-router/blob/db1f1fa487bc98552eaa47a18e562fd4e92cc365/router.js#L411-L412

A possible solution would be to bind clean to the instance during construction:

      }

      // Bind clean to instance to make it usable as event handler
      this.clean = this.clean.bind(this)

      this._setup(true, cfg)
    }

If that sounds feasible to you, I can prepare a PR.

I am unable to install

I am unable to install. He's sending it to a private directory on his github. The error in the created log record.
.
"install" "electron-router"
28 verbose node v10.15.3
29 verbose npm v6.11.3
30 error code ENOENT
31 error syscall spawn git
32 error path git
33 error errno ENOENT
34 error enoent Error while executing:
34 error enoent undefined ls-remote -h -t https://github.com/m0n0l0c0/eventemitter3.git
34 error enoent
34 error enoent
34 error enoent spawn git ENOENT
35 error enoent This is related to npm not being able to find a file.
36 verbose exit [ 1, true ]

Cannot unregister event

Hello Gentlemen,

we're using electron-router in combination with electron and React.
Received events are used to update some react states and consequently
UI elements.

When leaving React page, a certain method componentWillUnmount() gets called,
where we try to remove listeners in order to avoid React errors about updating unmounted
component.

Although removeListener() is correctly called, the event does not seem to de-register.
Next time when loading the tab, we get double the number of events. PLease look at
attached photo.

Do you have any idea about that?

Thanks,
Jure
image

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.