Skip to content

Commit

Permalink
Better semantic for names
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro authored and Maxime Mangel committed Feb 21, 2019
1 parent 40a8a24 commit 574cb35
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/react.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Program =

open Fable.Import.Browser

let withReactUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
let withReactBatchedUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
let mutable lastRequest = None
let setState model dispatch =
match lastRequest with
Expand All @@ -32,7 +32,7 @@ module Program =

{ program with setState = setState }

let withReactUnoptimizedUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
let withReactSynchronousUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) =
let setState model dispatch =
Fable.Import.ReactDom.render(
lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) program.view model dispatch,
Expand All @@ -50,15 +50,25 @@ module Program =

{ program with setState = setState }

/// Setup rendering of root React component inside html element identified by placeholderId
/// Renders React root component inside html element identified by placeholderId.
/// Uses `requestAnimationFrame` to batch updates to prevent drops in frame rate.
/// NOTE: This may have unexpected effects in React controlled inputs, see https://github.com/elmish/react/issues/12
let withReactBatched placeholderId (program:Elmish.Program<_,_,_,_>) =
Internal.withReactBatchedUsing lazyView2With placeholderId program

/// Renders React root component inside html element identified by placeholderId.
/// New renders are triggered immediately after an update.
let withReactSynchronous placeholderId (program:Elmish.Program<_,_,_,_>) =
Internal.withReactSynchronousUsing lazyView2With placeholderId program

[<System.Obsolete("Use withReactBatched")>]
let withReact placeholderId (program:Elmish.Program<_,_,_,_>) =
Internal.withReactUsing lazyView2With placeholderId program
Internal.withReactBatchedUsing lazyView2With placeholderId program

/// `withReact` uses `requestAnimationFrame` to optimize rendering in scenarios with updates at a higher rate than 60FPS, but this makes the cursor jump to the end in `input` elements.
/// This function works around the glitch if you don't need the optimization (see https://github.com/elmish/react/issues/12).
[<System.Obsolete("Use withReactSynchronous")>]
let withReactUnoptimized placeholderId (program:Elmish.Program<_,_,_,_>) =
Internal.withReactUnoptimizedUsing lazyView2With placeholderId program
Internal.withReactSynchronousUsing lazyView2With placeholderId program

/// Setup rendering of root React component inside html element identified by placeholderId using React.hydrate
/// Renders React root component inside html element identified by placeholderId using `React.hydrate`.
let withReactHydrate placeholderId (program:Elmish.Program<_,_,_,_>) =
Internal.withReactHydrateUsing lazyView2With placeholderId program

0 comments on commit 574cb35

Please sign in to comment.