Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Request animation frame #91

Merged
merged 5 commits into from
Apr 22, 2017

Conversation

coot
Copy link
Contributor

@coot coot commented Apr 13, 2017

Completes #90.

Marcin Szamotulski added 3 commits April 13, 2017 14:38
* `requestAnimationFrame :: forall eff. Eff (dom :: DOM | eff) Unit -> Window -> Eff (dom :: DOM | eff ) RequestAnimationFrameId`
* `cancelAnimationFrame :: forall eff. RequestAnimationFrameId -> Window -> Eff (dom :: DOM | eff) Unit`
* `requestIdleCallback :: forall eff. Eff (dom :: DOM | eff) Unit -> { timeout :: Int } -> Window -> Eff (dom :: DOM | eff ) RequestIdleCallbackId`
* `cancelIdleCallback :: forall eff. RequestIdleCallbackId -> { timeout :: Int } -> Window -> Eff (dom :: DOM | eff) Unit`

In the web api `timeout` option can be skipped, but one can always set
it to `0` to get the same behaviour (or just pass
`unsafeCoerce unit`).
Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a couple of things that could use tweaking / discussion.


exports._cancelAnimationFrame = function(id) {
return function(window) {
return window.cancelAnimationFrame(id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need an extra function() { wrapping the inner thing here as we're Eff-typing these things.


exports._cancelIdleCallback = function(id) {
return function(window) {
return window.cancelIdleCallback(id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this one!


newtype RequestAnimationFrameId = RequestAnimationFrameId Int

derive instance newtypeRequestAnimationFrameId :: Newtype RequestAnimationFrameId _
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you derive Eq and Ord for both of the newtypes introduced in here please?


foreign import _requestIdleCallback :: forall eff. Eff (dom :: DOM | eff) Unit -> { timeout :: Int } -> Window -> Eff (dom :: DOM | eff) Int

requestIdleCallback :: forall eff. Eff (dom :: DOM | eff) Unit -> { timeout :: Int } -> Window -> Eff (dom :: DOM | eff ) RequestIdleCallbackId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should put the options first here? Seems like a more natural ordering for currying perhaps.

Also, is timeout: 0 different from not specifying a value at all? If so, I guess we'll have to provide two varieties of requestIdleCallback to either accept options or not / have Maybe properties or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says that the timeout is only taken into account if it is a positive integer.

@garyb
Copy link
Member

garyb commented Apr 17, 2017

Thanks for making those changes, and adding the comment about 0 timeout. Just need those additional updates to the JS (adding the thunk for Eff), and also need to swap the arguments in the FFI to reflect the change in the PS file now.

* thunks for EFF
* swap arguments of cancelIdleCallback
@coot
Copy link
Contributor Author

coot commented Apr 17, 2017

Ups, I forgot to commit them. Here there are :)

@garyb
Copy link
Member

garyb commented Apr 22, 2017

Thanks!

@garyb garyb merged commit a657a4e into purescript-deprecated:master Apr 22, 2017
@coot coot deleted the requestAnimationFrame branch April 22, 2017 11:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants