ocsigen / eliom

Multi-tier framework for programming web and mobile applications in OCaml.
http://eliom.org
Other
299 stars 53 forks source link

Documentation on Eliom_notif is unclear #474

Open bluddy opened 7 years ago

bluddy commented 7 years ago

I'd like to have some dynamic notifications in my web app (ie. not just when the page is loaded) flowing from server->client or client->client. I'd like to avoid React for now since my last foray into FRP wasn't too great (in haskell). Using the Bus is one solution, and I may have to use that, but I'd like to try the Eliom_notif module first since it seems to fit my use-case more.

The documentation is unclear, though, and there isn't an example to illustrate how the functions would work.

  1. It's really unclear what identity is. I'm supposed to choose its type in the functor application, but then I have minimal access to it. I don't set it directly, and in the advanced Make I can get it, but I can't notify with it except for ?notfor, but since I'm not setting it, how do I get the values to exclude? It's all very confusing.
  2. When do I call init? Should it be called somewhere at the global level in a let%client block, or every time I load a client page?
  3. Similar to question 2, when do I need to register for listen?
  4. Why is init's interface monadic and listen's isn't?
  5. Not knowing React, client_ev is also confusing to understand. I haven't gotten to implementing this part yet though, and it may turn out easier than I expect.
  6. Is there app code that shows an example of this mechanism?
  7. Is this a good way to do dynamic client notifications? Would I be better off using a different mechanism in Eliom?
bluddy commented 7 years ago

BTW I ended up using the React interface and it works nicely. Definitely easier to use currently than the Eliom_notif interface, and I don't currently need the subscription mechanism (though that's obviously an advantage of notif).

leviroth commented 6 years ago

Documentation here would be really welcome. Where the documentation says, "Create a module for each kind of notifications you want using module Eliom_notif.​Simple. For example the notifications of new messages in a chat," it would be nice to see an example of such a module and its usage.

The documentation continues, "Each client process must register on each resource for which it wants to receive the the notifications (each chat currently opened, in our example), using function Eliom_notif.​Simple.​listen," but it's utterly unclear to me how I can create a module in such a way that it is accessible from the clients.