lichen-community-systems / Flocking

Flocking - Creative audio synthesis for the Web
GNU General Public License v2.0
695 stars 60 forks source link

A Flocking Environment instance can't be fully created using Infusion IoC #152

Closed colinbdclark closed 8 years ago

colinbdclark commented 8 years ago

Due to lingering factoring bugs related to #59, one cannot instantiate a flock.enviro without calling flock.init() directly.

It should be possible to do this:

fluid.defaults("flock.test.muzak", {
    gradeNames: "fluid.component",
    components: {
         enviro: {
            type: "flock.enviro"
        }
    }
});

And to expect that it creates a fully-working environment that can that have synths created within it. However, while flock.enviro currently is defined with the fluid.resolveRootSingle grade—making it a singleton within the IoC tree—this singleton isn't visible to old-style code that still expects to be able to grab a reference to the environment via the global flock.environment global variable.

I have created a [gist that shows a viable workaround[(https://gist.github.com/colinbdclark/7a6115f840274b722ea4). In the short term, this onCreate listener should be added directly to the flock.enviro grade, and in the medium-term, the incorrectly-named "parser" should be fully refactored as a component that can have an environment instance injected into it.