parkm / oldbpm

A JavaScript game where you shoot at bubbles.
0 stars 1 forks source link

Circular Dependencies #20

Closed parkm closed 10 years ago

parkm commented 10 years ago

We're starting to get some circular dependencies which RequireJS does not like. If a requires b and b requires a then one of them becomes undefined. So we need a way of solving this.

I was thinking that instead of using modules we should just require them in the main file, then give them a prefix. This would be easy to do since we're already exporting everything as object literals.

So bpm.js would look something like:

var currentState;
function setState() {}
var bpm = { setState: setState };

Just realized we can't do this since we can't have private variables.

We need the bpm module to be accessible by states, objects, and pretty much everything since it contains a lot of global stuff.

dgpt commented 10 years ago

Wait, where are these circular dependencies?

parkm commented 10 years ago

Currently there aren't any but there will be. If we wanted to switch states for instance in the states.js file.

dgpt commented 10 years ago

Fixing commits: 563ff80fa8e54a9ae9eace17dd002eb0ca23bdf5 295bf8166fe77f824523f0ee348e485eb5f9e55d bfe13eaf5913fe13097cf521ebd0b60d302e67ff