Neutralinojs v4.9.0 released!
API: Custom methods
Neutralinojs offers the extensions API to write custom backend code with any programming language, but extensions come with the following drawbacks that affect apps in several scenarios:
- Extensions use a shared WebSocket for communication, so using direct C++ references (i.e., the window handler) is impossible within extensions.
- The developer is responsible for packaging their extension binaries.
- A C++-based extension is not fast as native C++-based code due to the WebSockets-based IPC.
Alternatively, a developer can download the framework C++ code, modify it, and re-compile it. But, the developer may face issues while synching upstream code modifications. So, Neutralinojs offers a separate namespace, a function template, inbuilt helper functions (i.e., to get the window handler, validation, etc.), and a developer guide to add custom APIs to the Neutralinojs framework without updating the framework core.
let res = await Neutralino.custom.fetch('https://neutralino.js.org');
If developers make a custom API that others can use, we motivate them to contribute to the Neutralinojs framework by adding it to the main codebase.
let res = await Neutralino.net.fetch('https://neutralino.js.org');
If the developer adds a new custom method to the framework, the client library will automatically export it to the
Neutralino.custom namespace by using the
NL_CMETHODS internal global variable. The
Neutralino.custom.getMethods function returns an array of custom methods similar to
API: File streams
The current Neutralinojs API offers non-stream-based (Promise-based but synchronous-like) functions for working with files. For example, the
filesystem.readFile function reads the file content and retrieves data synchronously even though the WebSocket communication mechanism supports asynchronous patterns. However, the synchronous API lets developers work with files in a simple way, but they face the following issues in some scenarios:
- Reading large files is not performance-friendly (The whole file content gets loaded into the memory).
- Unable to work with dynamic file objects (i.e., Device files).
- File descriptors are not persistent within the app lifecycle as they get destroyed after native API calls.
To solve this issue, we offer an event-based file stream API with the following functions/events:
filesystem.openFile: Creates a file stream by openning a file.
filesystem.updateOpenedFile: Triggers a file
readAllevent or sets the file cursor.
filesystem.getOpenedFileInfo: Returns (awaited) information about the file stream (Props:
openedFile: Occurs per each file read event and whenever the file stream reaches
Update the config file option
4.9.0 and enter
neu update to fetch this version.
Get started: https://neutralino.js.org/docs
This release was auto-generated by ReleaseZri