Skip to content
Space Invaders
JavaScript CSS HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
src
.editorconfig
.eslintrc
.gitignore
README.markdown
index.html
package.json
webpack.config.js

README.markdown

Space Invaders

This is a project to explore the concept of Functional Reactive Programming (FRP) as much as possible in JavaScript.

Choice of FRP library

The libraries available in JavaScript at this time are not mature, but neither is FRP in general. This project's initial implementation will be in Kefir, which is almost the same as BaconJS, but faster (in simple terms).

Whilst RxJS has significant overlap with Kefir and BaconJS it is not considered FRP, and is as such unfit for the purposes of this project. It does however have many abstractions and layers that would possibly simplify some of the logic in this application, and may warrant investigation in the future.

A library called flyd also looks very exciting, and I will most likely attempt an implementation in flyd after Kefir.

Lessons Learnt

  • Many streams with timers causes large performance issues, a single timer that is filtered/mapped is much faster.
  • Streams all end up combined to be mapped to a view, the streams need to be properties at this point otherwise the stream with no value will block everything else.
  • Making a stream to represent two things e.g. Left AND Right arrow presses is probably a bad idea and will cause awkward behaviour. Create two streams and merge them instead.
  • JavaScript does not allow mutually recursive definitions (to creating a triangle dependency), to create a triangle shaped group of streams a pool must be created, consumed, and the stream added to the pool after the dependents have subscribed. Other implementations like Sodium abstract the pooling technique
  • A current limitation (possibly just of Kefir) is that all streams must be Properties (streams with an initial value, simply). This is because when many streams are merged the resulting stream will not have any values until all the streams it is comprised of have a value.

Resources

You can’t perform that action at this time.