How can we use dexie(indexedDB wrapper) in main process - dexie

Am building a electron app where am running network call in main process and database operations should be done from both main process and render process, as IndexedDB is browser based api we can access dexie directly in renderer process but main process throws exception as below:
"UnhandledPromiseRejectionWarning: MissingAPIError: indexedDB API missing".

Related

Emscripten threads and custom web workers

I wrote an app to process gcode files in C/C++ compiled using emscripten. File parsing and processing is done in std::threads. Displaying in webgl is done using Threejs on main browser thread.
Now, I need to do offscreen canvas with threejs in a web worker so I can speedup display. The ideal situation is where I could access Wasm from main browser thread and web worker, so I could load the 3d webgl data to send to threejs from the web worker, and fetch statistical data from the main browser thread to display to the user.
If I do send the wasm memory and wasm module to the javascript manually created webworker, I get some stack-pointer exception when calling wasm functions (as it seems emscripten with pthreads initialize a thread stack for every workers). I mean here that a copied, pasted some parts of myapp.worker.js generated by emscripten into a worker file, let's say myapp.threejs.worker.js.
I have these options:
Create a webworker form javascript, and access wasm only from this worker. Main browser thread must then communicate throught the worker to access wasm, affecting performance if some data is hardly transferable
Create a new thread in wasm, create a C api to call javascript and threejs in worker. The problem is, if a spawn a thread from wasm, I can not actually send the offscreen canvas to the web worker through wasm, unless I can communicate directly from javascript to web worker spawned by wasm.
Create a web worker from javascript, but communicate with wasm through main browser thread only. This approch suffers from UI blocking while receiving GL data, as it must pass on the UI thread.
My question is: is there a way to create a web worker from javascript and access wasm from web worker and main thread ? If not, is there a way to spawn a new web worker from wasm thread but post and receive message from javascript in main browser thread without passing through wasm ? Thanks.

Network calls within Electron React app

I'm new to electron and I want to make sure I understand the distinction between code that is appropriate for the main process vs the renderer process. The app is essentially a React app hosted inside a single electron page. So, as I understand it, I have one main process and one render process.
If I want to make REST calls as part of the React app (using axios for example), I assume I can do it inside the React code within the renderer process, right? No need to go to the main process for that is there?
I also have to create a socket connection to an outside server. This is not an HTTP REST interface, it's a raw TCP/IP socket. Can this also be done within the renderer process or do I need to go to the main for that?
I tried putting the socket calls using node's net library and it seems to work okay. The very first time I got some kind of connection error but subsequent tries seem to be working. That one error is making me wonder if using net inside the renderer is a good idea though.

Core data requests does not work on background thread when in app in background mode in Xcode

I execute core data request not on main thread when my app is called to do background fetch (app state is background), and method freezes forever.
But when I use main thread, it works.
Should I always use main thread for core data when in background mode? Does there is some apple doc about it?

How to access main application data from ScheduledAgent?

I would like to notify my main application (if it is still running) when the ScheduledAgent has finished its background task.
Is it actually possible? I couldn't figure out how I could reference my App or MainPage
For simply protecting shared data access between main app and background agent using Mutexes have a look at this question. Maybe this already gives you a hint in the right direction.
But if you want to react to events like "the background agent just finished" (in main app) or "the main app starts up" (in background agent) then you might be out of luck. There is no simple direct communication available, let alone direct data access. You could use Sockets or Raw Notifications.
A method based on polling and Mutexes is discussed in this question.

WP7 Periodic Task - What can I do within it

For a WP7 app I have managed to get a PeriodTask running as per some examples on msdn (sends out a toast message). Now looking to extend to do what I want.
The task is running in the background and I have no need for it to communicate with the foreground app if that is running. I am just a little unsure of what I am allowed to do within this background task, and what code I can access from it.
I would like to be able to access the database that I am using (Sterling) and then update a live tile. Presumably, since its running independently then I will need to open the database - do what I need to do re the tile and then close the database within this background process. This should be okay? And from within my ScheduledAgent class OnInvoke method I can call code that is defined on a class in my foreground project as long as I include a reference to that project in my ScheduledTask project. There are no issues with that code running inside my Background Periodic Task application?
thanks.
In a BackgroundAgent you can do anything apart from use the APIs in the unsupported list: http://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspx
The "Marketplace Test Kit" will detect use of any unsupported APIs.
In my solution I added a small Data Model project where I created a class to represent the data/model.
From the main app I store that instantiated object to the isolated storage. In the scheduletaskproject you can then just retrieve that stored instance from isolated storage if you also reference the small Model project.
If I'm not mistaken there is also a 5mb memory limit. So using a DB inside the scheduletaskproject could be a problem ( reference: http://csainty.blogspot.com/2011/08/wp75-mangobackground-agents.html )

Resources