Questions tagged [bs-webapi]

Use for questions relating to the bs-webapi BuckleScript bindings, and only with the [bucklescript] tag.

bs-webapi is a set of bindings to the DOM and other Web APIs.

8 questions
3
votes
1 answer

How to get innerHTML of each element in a node list

Say I have the following html:
one
two
three
I would like to log the innerHTML for each element. I have tried the following: document |> Document.querySelectorAll(".item") |>…
Sam Houston
  • 3,413
  • 2
  • 30
  • 46
2
votes
1 answer

Using HTML Canvas from ReasonML using React Hooks

I'm looking for a quick example on how to get started using the following technologies together: HTML5 Canvas ReasonML ReasonReact: "ReasonReact is a safer, simpler way to build React components, in Reason." bs-webapi: Web API bindings for…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
2
votes
1 answer

Having trouble getting event data from event listener in ReasonReact

I'm trying to implement dynamic column resizing on a table (like in Excel or Google Sheets). In my render function I use the handle callback when the user clicks mouse down on my resize control:
Homan
  • 25,618
  • 22
  • 70
  • 107
2
votes
1 answer

bs-webapi - How to loop over Dom.nodeList?

The following won't work since sides is a Dom.nodeList and DomTokenList.forEach expects a Dom.domTokenList. open Bs_webapi.Dom; external length : Dom.nodeList => int = "" [@@bs.get]; let sides = Document.querySelectorAll "#carousel > figure"…
Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
1
vote
1 answer

How to add a listener for all scroll events?

I need to add a listener for all scroll events in Reason React or all scroll affects affecting the main window (either would work). Trying this but the event does not trigger: open Webapi.Dom; Document.addEventListener("scroll", onScroll); P.S.…
Peteris
  • 3,548
  • 4
  • 28
  • 44
1
vote
1 answer

Add an event listener to the window

I am trying to add an event listener to the window, but I am unsure how to get the window. I currently have this. let onUnhandledRejection = (e) => { /* TODO: write this */ } WindowRe.addEventListener( "unhandledrejection", …
1
vote
1 answer

Pass results of querySelectorAll to EventTarget.addEventListener

I want to do something like: open Webapi.Dom; let addListener = (element) => EventTarget.addEventListener("click", onSubscribeClick, EventTarget.asEventTarget(element)); let addOrRemoveListeners = (handler, ()) => { let elements =…
Javier Chávarri
  • 1,605
  • 11
  • 21
0
votes
1 answer

How does fillStyle work in bs-webapi Canvas2d

I'm wondering how to create a and set a fill style using bs-webapi and Canvas2d interface in ReasonML. I think the definition I might need is this: let fillStyle = (ctx: t) => ctx |> fillStyle |> reifyStyle; But I'm having trouble understanding…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69