Git Product home page Git Product logo

electron-app-settings's People

Contributors

kettek avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

electron-app-settings's Issues

bundled code fails on renderer initialization

hey there,

i'm bundling my electron app which contains this package to handle settings with vue-cli-plugin-electron-builder which uses webpack to bundle js code.

i've noticed that my bundled/packaged code doesn't work and throws an exception like this:
image

since this is an atypical error message, i've managed to trace the cause of this down to this line:

require('electron').remote.require('electron-app-settings');

if i comment it out and just make sure that the main process has an instance of settings initialized, this error goes away and behavior is as expected.

does this qualify as a bug, or should i be trying to mess with webpack in order for this to be dynamically requirable?

Renderer doesn't "unregister" on close

When a renderer closes it doesn't unregister for events, this causes a "Object is distroyed" error in the main process if another renderer then tries to get or set settings.

I have worked around this by setting listeners as array and then creating a remove event. e.g
Main.js
let listeners = []; // ---- Register any listeners that request ipcMain.on('configurator-add-listener', (event) => { let listener = event.sender listeners.push(listener) // -- Send our settings over to the listener listener.send('configurator-master-set', {key: main_settings._storage}); }); // ---- Remove any listeners that request ipcMain.on('configurator-remove-listener', (event) => { let listener = event.sender listeners = listeners.filter(item => item !== listener) }); // -- Set our *set master events to listeners main_settings.on('set', (arg) => { listeners.forEach((listener)=>{ listener.send('configurator-master-set', arg); }) }); main_settings.on('unset', (arg) => { listeners.forEach((listener)=>{ listener.send('configurator-master-unset', arg); }) });

and then in Renderer,js
window.addEventListener('beforeunload', ()=>{ ipcRenderer.send('configurator-remove-listener'); return })

settings.get(key) return null when called to quick in render

My render calls settings.get(key) on window.DOMContentLoaded but it appears at this point the the render has not received the storage item via ipc channel 'configurator-master-set' yet and hence returns null even though the key exists in settings.

I solved this by waiting for ipcRenderer.on('configurator-master-set',()=>{ }); before calling settings.get(key) but perhaps settings.get() could wait for the initial set before it returns any values?

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.