Exemplo n.º 1
0
/**
 * Initialize the panel by creating a redux store, and render the root component.
 *
 * @param toolbox - The toolbox
 * @param perfFront - The Perf actor's front. Used to start and stop recordings.
 */
async function gInit(toolbox, perfFront, preferenceFront) {
  const store = createStore(reducers);

  // Do some initialization, especially with privileged things that are part of the
  // the browser.
  store.dispatch(actions.initializeStore({
    toolbox,
    perfFront,
    receiveProfile,
    // Pull the default recording settings from the reducer, and update them according
    // to what's in the target's preferences. This way the preferences are stored
    // on the target. This could be useful for something like Android where you might
    // want to tweak the settings.
    recordingSettingsFromPreferences: await getRecordingPreferences(
      preferenceFront,
      selectors.getRecordingSettings(store.getState())
    ),
    // Go ahead and hide the implementation details for the component on how the
    // preference information is stored
    setRecordingPreferences: () => setRecordingPreferences(
      preferenceFront,
      selectors.getRecordingSettings(store.getState())
    )
  }));

  ReactDOM.render(
    React.createElement(
      Provider,
      { store },
      React.createElement(Perf)
    ),
    document.querySelector("#root")
  );
}
Exemplo n.º 2
0
 return (dispatch, getState) => {
   if (typeof action !== "object") {
     throw new Error(
       "This function assumes that the dispatched action is a simple object and " +
       "synchronous."
     );
   }
   dispatch(action);
   const setRecordingPreferences = selectors.getSetRecordingPreferencesFn(getState());
   const recordingSettings = selectors.getRecordingSettings(getState());
   setRecordingPreferences(recordingSettings);
 };
Exemplo n.º 3
0
  function mountComponent() {
    store.dispatch(actions.initializeStore({
      perfFront: perfFrontMock,
      receiveProfile: receiveProfileMock,
      recordingSettingsFromPreferences: selectors.getRecordingSettings(store.getState()),
      setRecordingPreferences: recordingPreferencesMock,
    }));

    return ReactDOM.render(
      React.createElement(
        ReactRedux.Provider,
        { store },
        React.createElement(Perf)
      ),
      container
    );
  }
Exemplo n.º 4
0
 return (dispatch, getState) => {
   const recordingSettings = selectors.getRecordingSettings(getState());
   const perfFront = selectors.getPerfFront(getState());
   perfFront.startProfiler(recordingSettings);
   dispatch(changeRecordingState(REQUEST_TO_START_RECORDING));
 };
Exemplo n.º 5
0
 setRecordingPreferences: () => setRecordingPreferences(
   preferenceFront,
   selectors.getRecordingSettings(store.getState())
 )