Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Jan 19, 2024
2 parents c943ad9 + 464d52a commit 18b93e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions docs/reference/window.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ int main()
Nui::Window wnd1{};
std::unique_ptr<Nui::Window> wnd2{};

wnd.bind("myFunction", [&wnd2](nlohmann::json const&) {
wnd2 = std::make_unique<Nui::Window>();
wnd2->setSize(800, 600);
wnd2->setHtml("<html><body><h1>Hello World!</h1></body></html>");
wnd.bind("myFunction", [&wnd2, &wnd1](nlohmann::json const&) {
// required on windows to spawn the second window not from within this thread:
wnd1.dispatch([](){
wnd2 = std::make_unique<Nui::Window>();
wnd2->setSize(800, 600);
wnd2->setHtml("<html><body><h1>Hello World!</h1></body></html>");
});
});

wnd.run();
Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ All are disabled by default for security reasons.

### Usage

#### Backend
#### Backend
Registering a function that is callable from the frontend:
```cpp
#include <nui/backend/rpc_hub.hpp>
Expand All @@ -56,7 +56,7 @@ int main()

// highlight-start
hub.registerFunction(
"functionName",
"functionName",
// Parameters can either be be converted from json by nlohmann::json.get<decay_t<T>>...
[&hub](std::string const& responseId, int param2){
// ...
Expand All @@ -65,7 +65,7 @@ int main()
);

hub.registerFunction(
"functionName",
"functionName",
// ...or a nlohmann::json and you can dissect it yourself:
[](nlohmann::json const& args){
// ...
Expand Down Expand Up @@ -118,7 +118,7 @@ void foo()

// Useful RAII unregister (also available in backend):
{
auto unregisterWhenThisFallsOutOfScope =
auto unregisterWhenThisFallsOutOfScope =
Nui::RpcClient::autoRegisterFunction("asdf", [](){});
} // asdf no longer exists here.

Expand Down Expand Up @@ -165,7 +165,7 @@ void foo()

Example:
```cpp
#include <nui/filesystem/file_dialog.hpp>
#include <nui/frontend/filesystem/file_dialog.hpp>

void foo()
{
Expand Down Expand Up @@ -287,7 +287,7 @@ Nui::ThrottledFunction throttled;
void foo() {
throttle(
200 /*ms*/,
200 /*ms*/,
[](){
std::cout << "Not printed faster than 200ms after the last call.";
},
Expand Down Expand Up @@ -319,7 +319,7 @@ Nui::TimerHandle timer;
void foo()
{
Nui::setInterval(
500 /*ms*/,
500 /*ms*/,
// Called every 500ms
[](){std::cout << "Hello!\n";},
[&timer](Nui::TimerHandle&& t){
Expand Down

0 comments on commit 18b93e2

Please sign in to comment.