{"action":"created","issue":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/11347","repository_url":"https://api.github.com/repos/code-dot-org/code-dot-org","labels_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/11347/labels{/name}","comments_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/11347/comments","events_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/11347/events","html_url":"https://github.com/code-dot-org/code-dot-org/pull/11347","id":185190021,"number":11347,"title":"Kill initApp.js in favor of a single app entry point.","user":{"login":"pcardune","id":124827,"avatar_url":"https://avatars.githubusercontent.com/u/124827?v=3","gravatar_id":"","url":"https://api.github.com/users/pcardune","html_url":"https://github.com/pcardune","followers_url":"https://api.github.com/users/pcardune/followers","following_url":"https://api.github.com/users/pcardune/following{/other_user}","gists_url":"https://api.github.com/users/pcardune/gists{/gist_id}","starred_url":"https://api.github.com/users/pcardune/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcardune/subscriptions","organizations_url":"https://api.github.com/users/pcardune/orgs","repos_url":"https://api.github.com/users/pcardune/repos","events_url":"https://api.github.com/users/pcardune/events{/privacy}","received_events_url":"https://api.github.com/users/pcardune/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"islemaster","id":1615761,"avatar_url":"https://avatars.githubusercontent.com/u/1615761?v=3","gravatar_id":"","url":"https://api.github.com/users/islemaster","html_url":"https://github.com/islemaster","followers_url":"https://api.github.com/users/islemaster/followers","following_url":"https://api.github.com/users/islemaster/following{/other_user}","gists_url":"https://api.github.com/users/islemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/islemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/islemaster/subscriptions","organizations_url":"https://api.github.com/users/islemaster/orgs","repos_url":"https://api.github.com/users/islemaster/repos","events_url":"https://api.github.com/users/islemaster/events{/privacy}","received_events_url":"https://api.github.com/users/islemaster/received_events","type":"User","site_admin":false},"assignees":[{"login":"islemaster","id":1615761,"avatar_url":"https://avatars.githubusercontent.com/u/1615761?v=3","gravatar_id":"","url":"https://api.github.com/users/islemaster","html_url":"https://github.com/islemaster","followers_url":"https://api.github.com/users/islemaster/followers","following_url":"https://api.github.com/users/islemaster/following{/other_user}","gists_url":"https://api.github.com/users/islemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/islemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/islemaster/subscriptions","organizations_url":"https://api.github.com/users/islemaster/orgs","repos_url":"https://api.github.com/users/islemaster/repos","events_url":"https://api.github.com/users/islemaster/events{/privacy}","received_events_url":"https://api.github.com/users/islemaster/received_events","type":"User","site_admin":false},{"login":"Bjvanminnen","id":1767466,"avatar_url":"https://avatars.githubusercontent.com/u/1767466?v=3","gravatar_id":"","url":"https://api.github.com/users/Bjvanminnen","html_url":"https://github.com/Bjvanminnen","followers_url":"https://api.github.com/users/Bjvanminnen/followers","following_url":"https://api.github.com/users/Bjvanminnen/following{/other_user}","gists_url":"https://api.github.com/users/Bjvanminnen/gists{/gist_id}","starred_url":"https://api.github.com/users/Bjvanminnen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bjvanminnen/subscriptions","organizations_url":"https://api.github.com/users/Bjvanminnen/orgs","repos_url":"https://api.github.com/users/Bjvanminnen/repos","events_url":"https://api.github.com/users/Bjvanminnen/events{/privacy}","received_events_url":"https://api.github.com/users/Bjvanminnen/received_events","type":"User","site_admin":false},{"login":"caleybrock","id":4640747,"avatar_url":"https://avatars.githubusercontent.com/u/4640747?v=3","gravatar_id":"","url":"https://api.github.com/users/caleybrock","html_url":"https://github.com/caleybrock","followers_url":"https://api.github.com/users/caleybrock/followers","following_url":"https://api.github.com/users/caleybrock/following{/other_user}","gists_url":"https://api.github.com/users/caleybrock/gists{/gist_id}","starred_url":"https://api.github.com/users/caleybrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caleybrock/subscriptions","organizations_url":"https://api.github.com/users/caleybrock/orgs","repos_url":"https://api.github.com/users/caleybrock/repos","events_url":"https://api.github.com/users/caleybrock/events{/privacy}","received_events_url":"https://api.github.com/users/caleybrock/received_events","type":"User","site_admin":false},{"login":"cpirich","id":5429146,"avatar_url":"https://avatars.githubusercontent.com/u/5429146?v=3","gravatar_id":"","url":"https://api.github.com/users/cpirich","html_url":"https://github.com/cpirich","followers_url":"https://api.github.com/users/cpirich/followers","following_url":"https://api.github.com/users/cpirich/following{/other_user}","gists_url":"https://api.github.com/users/cpirich/gists{/gist_id}","starred_url":"https://api.github.com/users/cpirich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpirich/subscriptions","organizations_url":"https://api.github.com/users/cpirich/orgs","repos_url":"https://api.github.com/users/cpirich/repos","events_url":"https://api.github.com/users/cpirich/events{/privacy}","received_events_url":"https://api.github.com/users/cpirich/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2016-10-25T17:59:46Z","updated_at":"2016-11-02T22:19:45Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/pulls/11347","html_url":"https://github.com/code-dot-org/code-dot-org/pull/11347","diff_url":"https://github.com/code-dot-org/code-dot-org/pull/11347.diff","patch_url":"https://github.com/code-dot-org/code-dot-org/pull/11347.patch"},"body":"So, we had a really complicated page initialization pipeline that used to be necessary but is no longer necessary. Here is how it used to work:\r\n1. page loads `initApp.js`, which adds a `window.apps.setupApp()` function and a `window.apps.load()` function.\r\n2. page loads `applab.js`, which adds a `window.applabMain()` function.\r\n3. page creates a global `appOptions` variable with config from the server.\r\n4. page calls `window.apps.setupApp()` which mutates `appOptions`.\r\n5. page calls `window.apps.load()` which extracts out the app name (\"applab\") from the `appOptions` globals, and then calls `window[app+'Main']()`\r\n\r\nHere is how it works after this change:\r\n1. page loads `applab.js`, which extracts appOptions from script tag's `data-appoptions` attribute, and does all the necessary setup.\r\n2. [_ed: Profit!_]\r\n\r\nThe End.\r\n\r\nNow for some more details on what things got moved where to arrive at this diff:\r\n\r\n1. For every app, there is now a `src/sites/studio/pages/levels-<appname>-main.js` which serves as the entry point into the entire javascript execution stack for that app's page. Rather than exposing global functions that the page must call, it just executes as soon as it is loaded. These \"main\" files replace what use to be a combination of `initApp.js` and `src/<appname>/main.js`.\r\n\r\n2. For integration tests, we actually need to control when the execution happens, and don't want to load the entry points directly. For this reason, the entry points are really dumb (as they should be), and hand off their work to special loader functions in `src/sites/studio/pages/init/load<Appname>.js`. These loader functions perform the small amount of configuration needed by each app.\r\n\r\n3. The bulk of the common initialization code used by every app that used to live in the `initApp.js` entry point has been moved to `src/code-studio/initApp/loadApp.js` where the loadApp function is exposed through regular es6 module exports. The `levels-<appname>-main.js` entry points are responsible for calling `loadApp` themselves.\r\n\r\n4. The `loadApp()` function will actually load a bunch of data from the server relating to the user's current progress on a given level. In the scenario where we are only embedding blocks in html pages, we skip this step as it is unnecessary. So, appOptions now has a new parameter called `embedded` which indicates that this app is being loaded in an embedded context.\r\n\r\nThere is lots of more simplification that can be done, but I'm going to stop here for the moment so I don't change too many things at the same time. But here is what I plan to do next:\r\n\r\n- refactor and rename `loadApp` so it better describes what it is actually doing.\r\n- try to kill off the various `load<Appname>.js` files which just contain boilerplate configuration in favor of another more straightforward configuration system.\r\n- remove the use of various globals that get attached to the window object at unpredictable points\r\n- find some way to document what everything inside appOptions is and what it controls.\r\n"},"comment":{"url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/comments/258017008","html_url":"https://github.com/code-dot-org/code-dot-org/pull/11347#issuecomment-258017008","issue_url":"https://api.github.com/repos/code-dot-org/code-dot-org/issues/11347","id":258017008,"user":{"login":"Bjvanminnen","id":1767466,"avatar_url":"https://avatars.githubusercontent.com/u/1767466?v=3","gravatar_id":"","url":"https://api.github.com/users/Bjvanminnen","html_url":"https://github.com/Bjvanminnen","followers_url":"https://api.github.com/users/Bjvanminnen/followers","following_url":"https://api.github.com/users/Bjvanminnen/following{/other_user}","gists_url":"https://api.github.com/users/Bjvanminnen/gists{/gist_id}","starred_url":"https://api.github.com/users/Bjvanminnen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bjvanminnen/subscriptions","organizations_url":"https://api.github.com/users/Bjvanminnen/orgs","repos_url":"https://api.github.com/users/Bjvanminnen/repos","events_url":"https://api.github.com/users/Bjvanminnen/events{/privacy}","received_events_url":"https://api.github.com/users/Bjvanminnen/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T22:19:45Z","updated_at":"2016-11-02T22:19:45Z","body":"I'm both excited and a little terrified to get this stuff in. It seems like the sort of thing that we want to get merged as soon as possible, or wait until after hour of code. Hopefully we can accomplish the former without running into too many edge cases we didnt think of."}}
{"actor":{"display_login":"Bjvanminnen"}}