summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-06-15 02:15:10 +0700
committerpolwex <polwex@sortug.com>2025-06-15 02:15:10 +0700
commit8b7ee88a6a4c7f1209ebe180241c928049a67162 (patch)
tree570a3860327df1d218a86952c2a54be104ae63f7
parent69312f5133734237edaea6ca29e2de9bf3203050 (diff)
well that was smooth
-rw-r--r--bs5/dune-project1
-rw-r--r--bs5/universal/native/FunctionReferences.re5
-rw-r--r--bs5/universal/native/FunctionReferences.rei1
-rw-r--r--bs5/universal/native/dune4
-rw-r--r--bs5/universal/native/shared/ServerFunctions.re6
5 files changed, 12 insertions, 5 deletions
diff --git a/bs5/dune-project b/bs5/dune-project
index e5f8d85..8445b07 100644
--- a/bs5/dune-project
+++ b/bs5/dune-project
@@ -33,6 +33,7 @@
melange
melange-json
melange-json-native
+ melange-native
ocamlformat
(melange-webapi :with-dev-setup)
(melange-fetch :with-dev-setup)
diff --git a/bs5/universal/native/FunctionReferences.re b/bs5/universal/native/FunctionReferences.re
new file mode 100644
index 0000000..b7722be
--- /dev/null
+++ b/bs5/universal/native/FunctionReferences.re
@@ -0,0 +1,5 @@
+type t = Hashtbl.t(string, ReactServerDOM.server_function);
+
+let registry = Hashtbl.create(10);
+let register = Hashtbl.add(registry);
+let get = Hashtbl.find_opt(registry);
diff --git a/bs5/universal/native/FunctionReferences.rei b/bs5/universal/native/FunctionReferences.rei
new file mode 100644
index 0000000..6562fc4
--- /dev/null
+++ b/bs5/universal/native/FunctionReferences.rei
@@ -0,0 +1 @@
+include ReactServerDOM.FunctionReferences;
diff --git a/bs5/universal/native/dune b/bs5/universal/native/dune
index 942f192..158b58a 100644
--- a/bs5/universal/native/dune
+++ b/bs5/universal/native/dune
@@ -1,7 +1,7 @@
(include_subdirs unqualified)
(library
- (name demo_shared_native)
+ (name shared)
(flags :standard -w -26-27) ; browser_only removes code form the server, making this warning necessary
(libraries
server-reason-react.react
@@ -21,7 +21,7 @@
(preprocess
(pps
lwt_ppx
- server-reason-react.melange.ppx
+ server-reason-react.melange_ppx
server-reason-react.ppx
server-reason-react.browser_ppx
melange-json-native.ppx)))
diff --git a/bs5/universal/native/shared/ServerFunctions.re b/bs5/universal/native/shared/ServerFunctions.re
index 24d94a5..acadbd1 100644
--- a/bs5/universal/native/shared/ServerFunctions.re
+++ b/bs5/universal/native/shared/ServerFunctions.re
@@ -3,7 +3,7 @@ open Melange_json.Primitives;
module Notes = {
[@react.server.function]
let create = (~title: string, ~content: string): Js.Promise.t(Note.t) => {
- let note = DB.addNote(~title, ~content);
+ let note = DB.add_note(~title, ~content);
let%lwt response =
switch%lwt (note) {
| Ok(note) => Lwt.return(note)
@@ -15,7 +15,7 @@ module Notes = {
[@react.server.function]
let edit =
(~id: int, ~title: string, ~content: string): Js.Promise.t(Note.t) => {
- let note = DB.editNote(~id, ~title, ~content);
+ let note = DB.edit_note(~id, ~title, ~content);
let%lwt response =
switch%lwt (note) {
| Ok(note) => Lwt.return(note)
@@ -27,7 +27,7 @@ module Notes = {
[@react.server.function]
let delete_ = (~id: int): Js.Promise.t(string) => {
- let _ = DB.deleteNote(id);
+ let _ = DB.delete_note(id);
Lwt.return("Note deleted");
};
};