createDispatchers

Create action dispatcher wrappers with bound playerID and credentials
545070
function createDispatchers(
  storeActionType,
  innerActionNames,
  store,
  playerID,
  credentials,
  multiplayer
) {
  return innerActionNames.reduce((dispatchers, name) => {
    dispatchers[name] = function(...args) {
      let assumedPlayerID = playerID;

      // In singleplayer mode, if the client does not have a playerID
      // associated with it, we attach the currentPlayer as playerID.
      if (!multiplayer && (playerID === null || playerID === undefined)) {
        const state = store.getState();
        assumedPlayerID = state.ctx.currentPlayer;
      }

      store.dispatch(
        ActionCreators[storeActionType](
          name,
          args,
          assumedPlayerID,
          credentials
        )
      );
    };
    return dispatchers;
  }, {});
}
1062409
function makeReactive(componentDefinition, renderFn, ...stateStreamNames) {
  class ReactiveComponent extends PureComponent {
    constructor(props, context) {
      super(props, context);
      this.state = { childProps: {} }
      this.omnistream = this.context.omnistream;

      // Make the dispatch function accessible to be passed as a prop to child components.
      this.dispatch = this.omnistream.dispatch.bind(context.omnistream);
      this.dispatchObservableFn = this.omnistream.dispatchObservableFn.bind(context.omnistream);
    }

    componentDidMount() {
      // Creates a new substream for each action type based on the provided "streamNames"
      const stateStreams = stateStreamNames.map(name => this.omnistream.store[name]);
      const state$ = combineStreamsToState(stateStreams);
      // Subscribes to the props stream. This will trigger a re-render whenever a new action has been dispatched to 
      // any filtered stream passed down as props to a component.
      this.subscription = state$.subscribe((props) => {
        this.setState({ childProps: Object.assign({}, this.props, props) });
      });
    }

    componentWillUnmount() {
      this.subscription.unsubscribe();
    }

    render() {
      return renderFn.call(this, componentDefinition);
    }
  }
  ReactiveComponent.contextTypes = { omnistream: React.PropTypes.object.isRequired }
  return ReactiveComponent;
}
428324
public static function customDispatcher($className, $action, $params)
    {
        $dispatcher = new self;
        $dispatcher->setClassName($className);
        $dispatcher->setAction($action);
        $dispatcher->setParams($params);

        return $dispatcher;
    }
1303410
def create_dispatcher(self):
        
        before_context = max(self.args.before_context, self.args.context)
        after_context = max(self.args.after_context, self.args.context)

        if self.args.files_with_match is not None or self.args.count or self.args.only_matching or self.args.quiet:
            # Sending of log lines disabled by arguments
            return UnbufferedDispatcher(self._channels)
        elif before_context == 0 and after_context == 0:
            # Don't need line buffering
            return UnbufferedDispatcher(self._channels)
        elif self.args.thread:
            return ThreadedDispatcher(self._channels, before_context, after_context)
        else:
            return LineBufferDispatcher(self._channels, before_context, after_context)
761533
public EventDispatcher getEventDispatcher(EventPublisher source) {
	EventDispatcher ret = dispatchers.get(source);
	if (ret == null) {
	    ret = createDispatcher(source);
	}
	return ret;
    }
1374381
SibRaDispatcher createDispatcher(final AbstractConsumerSession session,
                                     final Reliability unrecoveredReliability,
                                     final int maxFailedDeliveries,
                                     final int sequentialFailureThreshold)
                    throws ResourceException {

        final String methodName = "createDispatcher";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName,
                        new Object[] { session, unrecoveredReliability, maxFailedDeliveries, sequentialFailureThreshold });
        }

        if (_closed) {

            throw new IllegalStateException(NLS
                            .getString("LISTENER_CLOSED_CWSIV0953"));

        }

        final SibRaDispatcher dispatcher;

        if (_endpointActivation.isEndpointMethodTransactional()) {

            if (_endpointConfiguration.getShareDataSourceWithCMP()) {

                dispatcher = new SibRaSynchronizedDispatcher(this,
                                session, _endpointActivation, unrecoveredReliability, maxFailedDeliveries,
                                sequentialFailureThreshold);

            } else {

                dispatcher = new SibRaTransactionalDispatcher(this,
                                session, _endpointActivation, _busName, unrecoveredReliability, maxFailedDeliveries,
                                sequentialFailureThreshold);

            }

        } else {

            if (SibRaMessageDeletionMode.BATCH.equals(_endpointConfiguration
                            .getMessageDeletionMode())) {

                dispatcher = new SibRaBatchMessageDeletionDispatcher(
                                this, session, _endpointActivation, unrecoveredReliability, maxFailedDeliveries,
                                sequentialFailureThreshold);

            } else if (SibRaMessageDeletionMode.SINGLE
                            .equals(_endpointConfiguration.getMessageDeletionMode())) {

                dispatcher = new SibRaSingleMessageDeletionDispatcher(
                                this, session, _endpointActivation, unrecoveredReliability, maxFailedDeliveries,
                                sequentialFailureThreshold);

            } else {

                dispatcher = new SibRaNonTransactionalDispatcher(this,
                                session, _endpointActivation, unrecoveredReliability, maxFailedDeliveries,
                                sequentialFailureThreshold);

            }

        }

        _dispatcherCount.incrementAndGet();
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
            SibTr.debug(this, TRACE, "Creating a dispatcher, there are now " + _dispatcherCount.get() + " open dispatchers");
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName, dispatcher);
        }
        return dispatcher;

    }
177485
@Override
    public IPortletActionExecutionWorker createActionWorker(
            HttpServletRequest request,
            HttpServletResponse response,
            IPortletWindowId portletWindowId) {
        final IPortletWindow portletWindow =
                this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
        return new PortletActionExecutionWorker(
                portletThreadPool,
                executionInterceptors,
                portletRenderer,
                request,
                response,
                portletWindow);
    }
104782
def action_factory(name, parameter=False):
    
    if parameter:
        return partial(ParameterizedActionNeed, name)
    else:
        return ActionNeed(name)
1016016
@Override
    public void createControlAdapter()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "createControlAdapter");

        DestinationHandler dh = null;
        try
        {
            ReferenceStream rs = getReferenceStream();
            if (rs instanceof MessageReferenceStream)
            {
                ItemStream is = rs.getItemStream();
                if (is instanceof PubSubMessageItemStream)
                {
                    dh = ((PubSubMessageItemStream) is).getDestinationHandler();
                    controlAdapter = new QueuedMessage(this, dh, rs);
                }
            }
        } catch (Exception e)
        {
            // FFDC
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.store.items.MessageItemReference.createControlAdapter",
                                        "1:1266:1.147",
                                        this);

            SibTr.exception(tc, e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createControlAdapter");
    }
119426
public <T extends InvocationMarshaller<?>> T registerDispatcher (
        InvocationDispatcher<T> dispatcher)
    {
        return registerDispatcher(dispatcher, null);
    }
973579
function loadPlayer(playerCode) {
  const sandbox = vm.createContext();

  // Do not collect stack frames for errors in the player code.
  vm.runInContext('Error.stackTraceLimit = 0;', sandbox);

  try {
    vm.runInContext(playerCode, sandbox, {
      filename: playerCodeFilename,
      timeout: playerCodeTimeout,
    });
  } catch (err) {
    const error = new Error(`Check your syntax and try again!\n\n${err.stack}`);
    error.code = 'InvalidPlayerCode';
    throw error;
  }

  try {
    const player = vm.runInContext('new Player();', sandbox, {
      timeout: playerCodeTimeout,
    });
    assert(typeof player.playTurn === 'function', 'playTurn is not defined');
    const playTurn = turn => {
      try {
        player.playTurn(turn);
      } catch (err) {
        const error = new Error(err.message);
        error.code = 'InvalidPlayerCode';
        throw error;
      }
    };
    return playTurn;
  } catch (err) {
    if (err.message === 'Player is not defined') {
      const error = new Error('You must define a Player class!');
      error.code = 'InvalidPlayerCode';
      throw error;
    } else if (err.message === 'playTurn is not defined') {
      const error = new Error(
        'Your Player class must define a playTurn method!',
      );
      error.code = 'InvalidPlayerCode';
      throw error;
    }

    throw err;
  }
}
984125
function byNameDispatcher(keysArray, objectWithDispatchMethods) {
  return function handleOrRecurse(singleSignalK) {
    if (typeof singleSignalK === 'object' && singleSignalKx !== null) {
    var branchName = Object.keys(singleSignalK)[0];
    if (keysArray.indexOf(branchName) != -1) {
      var dispatcherFunction = objectWithDispatchMethods['handle_' + branchName];
      if (typeof dispatcherFunction === 'function') {
        dispatcherFunction.bind(objectWithDispatchMethods);
        dispatcherFunction.call(objectWithDispatchMethods, singleSignalK[branchName].value);
      } else {
        console.error("No method named handle_" + branchName + " found");
        console.error(JSON.stringify(objectWithDispatchMethods));
      }
    } else {
      handleOrRecurse(singleSignalK[branchName]);
    }
  }
  }
}
336027
protected void createAndAddEventHandlers(PlayerSession playerSession)
	{
		// Create a network event listener for the player session.
		EventHandler networkEventHandler = new NetworkEventListener(playerSession);
		// Add the handler to the game room's EventDispatcher so that it will
		// pass game room network events to player session session.
		this.eventDispatcher.addHandler(networkEventHandler);
		LOG.trace("Added Network handler to "
				+ "EventDispatcher of GameRoom {}, for session: {}", this,
				playerSession);
	}
205482
function createNextAsyncAction (actionFunc, outputs) {
  var resolver = null;
  var promise = new Promise((resolve) => resolver = resolve);
  var fn = createNextFunction(actionFunc, resolver);
  addOutputs(fn, outputs);

  return { fn, promise };
}
858888
public void addDispatcher(String dispatcherId) {
        addDispatcher(dispatcherId, new ActorDispatcher(dispatcherId, this, Runtime.getRuntime().availableProcessors()));
    }
624030
function (dispatcher) {

    if (dispatchers.isDispatcher(dispatcher)) {
      this.dispatcher = dispatcher;
    } else {
      this.dispatcher = new dispatchers.Dispatcher();
    }

    this.tokens = [];

    this.resetProps();
    this.resetState();

    var name = this.constructor.name;
    var trace;
    var handler;

    if (factory.isFunction(this.storeWillMount)) {
      trace = new Error(name + ': storeWillMount handler error');
      handler = this.catchError(this.storeWillMount.bind(this), trace);
      this.on('storeWillMount', handler);
    }

    if (factory.isFunction(this.storeWillUnmount)) {
      trace = new Error(name + ': storeWillUnmount handler error');
      handler = this.catchError(this.storeWillUnmount.bind(this), trace);
      this.on('storeWillUnmount', handler);
    }

    if (factory.isFunction(this.storeWillReceiveProps)) {
      trace = new Error(name + ': storeWillReceiveProps handler error');
      handler = this.catchError(this.storeWillReceiveProps.bind(this), trace);
      this.on('storeWillReceiveProps', handler);
    }
  }
364750
private void outputMemberInjections(GinjectorBindings bindings, FragmentMap fragments,
      SourceWriteUtil sourceWriteUtil) {
    NameGenerator nameGenerator = bindings.getNameGenerator();
    for (TypeLiteral<?> type : bindings.getMemberInjectRequests()) {
      if (!reachabilityAnalyzer.isReachableMemberInject(bindings, type)) {
        continue;
      }

      List<InjectorMethod> memberInjectionHelpers = new ArrayList<InjectorMethod>();

      try {
        sourceWriteUtil.createMemberInjection(type, nameGenerator, memberInjectionHelpers);
        outputMethods(memberInjectionHelpers, fragments);
      } catch (NoSourceNameException e) {
        errorManager.logError(e.getMessage(), e);
      }
    }
  }