Skip to content

This module provides a game / animation loop based upon requestAnimationFrame.

Notifications You must be signed in to change notification settings

garethwhittaker/rxjs-animation-loop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RxJS Animation Loop

This module provides a game / animation loop based upon requestAnimationFrame.

Installation and Usage

npm install rxjs-animation-loop

Note: rxjs (5.x) is a peer dependency of this package.

import animationLoop from 'rxjs-animation-loop'

const gameLoop = animationLoop()

gameLoop.start()

const gameLoopSubscription = gameLoop.subscribe(() => {
    // code to perform each animation frame
})

// several levels later ...

gameLoopSubscription.unsubscribe()

gameLoop.stop()

Further examples are provided within the src directory. View the output of these with:

npm run example-multiple-subscribers
npm run example-pausing-game-loop

About

This module provides a game / animation loop based upon requestAnimationFrame.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published