adds new event hooks for an item
NOTE: this has to be called before adding the first items, as this won't be called anymore after the ViewHolders were created

@param eventHooks the event hooks to be added for an item
@return this
358554
public FastAdapter<Item> withEventHooks(@Nullable Collection<? extends EventHook<Item>> eventHooks) {
        if (eventHooks == null) {
            return this;
        }
        if (this.eventHooks == null) {
            this.eventHooks = new LinkedList<>();
        }
        this.eventHooks.addAll(eventHooks);
        return this;
    }
443165
public ProjectHook modifyHook(ProjectHook hook) throws GitLabApiException {

        GitLabApiForm formData = new GitLabApiForm()
            .withParam("url", hook.getUrl(), true)
            .withParam("push_events", hook.getPushEvents(), false)
            .withParam("issues_events", hook.getIssuesEvents(), false)
            .withParam("merge_requests_events", hook.getMergeRequestsEvents(), false)
            .withParam("tag_push_events", hook.getTagPushEvents(), false)
            .withParam("note_events", hook.getNoteEvents(), false)
            .withParam("job_events", hook.getJobEvents(), false)
            .withParam("pipeline_events", hook.getPipelineEvents(), false)
            .withParam("wiki_events", hook.getWikiPageEvents(), false)
            .withParam("enable_ssl_verification", hook.getEnableSslVerification(), false)
            .withParam("token", hook.getToken(), false);

        Response response = put(Response.Status.OK, formData.asMap(), "projects", hook.getProjectId(), "hooks", hook.getId());
        return (response.readEntity(ProjectHook.class));
    }
259782
public static void addShutdownHook(Runnable hook) {
		Runtime.getRuntime().addShutdownHook((hook instanceof Thread) ? (Thread) hook : new Thread(hook));
	}
338304
protected static function addEventHandlers()
    {
        $eventManager = EventManager::getInstance();

        foreach (static::$handlers as $module => $handlers) {
            foreach ($handlers as $event => $handler) {
                $eventManager->addEventHandler($module, $event, [__CLASS__, $handler], false, 5000);
            }
        }

        $eventManager->addEventHandler('main', 'OnAfterEpilog', function () {
            $notifier = new Notifier();
            $notifier->deleteNotificationFromPreviousMigration();

            return new EventResult();
        });
    }
1277158
public void setConnectionHookClassName(String connectionHookClassName) {
		this.connectionHookClassName = checkNotNull(connectionHookClassName);
			Object hookClass;
			try {
				hookClass = loadClass(connectionHookClassName).newInstance();
				this.connectionHook = (ConnectionHook) hookClass;
			} catch (Exception e) {
				logger.error("Unable to create an instance of the connection hook class ("+connectionHookClassName+")");
				this.connectionHook = null;
			} 
	}
88212
public static WebhookMessage embeds(MessageEmbed first, MessageEmbed... embeds)
    {
        Checks.notNull(first,   "Embeds");
        Checks.noneNull(embeds, "Embeds");
        List<MessageEmbed> list = new ArrayList<>(1 + embeds.length);
        list.add(first);
        Collections.addAll(list, embeds);
        return new WebhookMessage(null, null, null, list, false, null);
    }
1141195
function addHook (hook) {
    /* Accepting a nodeback, promisify it; else, store as it */
    const pHook = (hook.length > 1) ? Promise.promisify(hook) : hook;
    G.hooks.push(pHook);
}
1135054
public final ZMonitor add(Event... events)
    {
        if (started) {
            System.out.println("ZMonitor: Unable to add events while already started.");
            return this;
        }
        ZMsg msg = new ZMsg();
        msg.add(ADD_EVENTS);
        for (Event evt : events) {
            msg.add(evt.name());
        }
        agent.send(msg);
        agent.recv();
        return this;
    }
1363523
public EventBuilder withContexts(Map<String, Map<String, Object>> contexts) {
        event.setContexts(contexts);
        return this;
    }
480517
protected Function<GitHubRepositoryName, GHHook> createHookSubscribedTo(final List<GHEvent> events) {
        return new NullSafeFunction<GitHubRepositoryName, GHHook>() {
            @Override
            protected GHHook applyNullSafe(@Nonnull GitHubRepositoryName name) {
                try {
                    GHRepository repo = checkNotNull(
                            from(name.resolve(allowedToManageHooks())).firstMatch(withAdminAccess()).orNull(),
                            "There are no credentials with admin access to manage hooks on %s", name
                    );

                    Validate.notEmpty(events, "Events list for hook can't be empty");

                    Set<GHHook> hooks = from(fetchHooks().apply(repo))
                            .filter(webhookFor(endpoint))
                            .toSet();

                    Set<GHEvent> alreadyRegistered = from(hooks)
                            .transformAndConcat(eventsFromHook()).toSet();

                    if (hooks.size() == 1 && isEqualCollection(alreadyRegistered, events)) {
                        LOGGER.debug("Hook already registered for events {}", events);
                        return null;
                    }

                    Set<GHEvent> merged = from(alreadyRegistered).append(events).toSet();

                    from(hooks)
                            .filter(deleteWebhook())
                            .filter(log("Replaced hook")).toList();

                    return createWebhook(endpoint, merged).apply(repo);
                } catch (Exception e) {
                    LOGGER.warn("Failed to add GitHub webhook for {}", name, e);
                    GitHubHookRegisterProblemMonitor.get().registerProblem(name, e);
                }
                return null;
            }
        };
    }
197844
public void setRefreshCompleteHook(PtrUIHandlerHook hook) {
        mRefreshCompleteHook = hook;
        hook.setResumeAction(new Runnable() {
            @Override
            public void run() {
                if (DEBUG) {
                    PtrCLog.d(LOG_TAG, "mRefreshCompleteHook resume.");
                }
                notifyUIRefreshComplete(true);
            }
        });
    }
1002592
function addHookByType(ctx, type, methodNames, fn) {
  let i = methodNames.length;

  // If no hook specified, add wildcard
  if (i === 0) {
    methodNames = ['*'];
    i = 1;
  }

  let hookType = `${type}Hooks`;

  if (!ctx[hookType]) ctx[hookType] = {};

  while (i--) {
    let methodName = methodNames[i];
    // for array method names
    if (Array.isArray(methodName)) {
      addHookByType(ctx, type, methodName, fn);
    } else {
      if (!ctx[hookType][methodName]) {
        ctx[hookType][methodName] = [fn];
      } else {
        ctx[hookType][methodName].push(fn);
      }
    }
  }
}
271558
public void addHandler(AptEvent event, AptMethod eventHandler)
    {
        assert event.getEventSet() == _eventSet;
        _handlerMap.put(event, eventHandler);
    }
1334151
private void bindEvents() {
		visibilityToggle.addClickHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				if (visibilityToggle.isEnabled()) {
					layer.setMarkedAsVisible(!layer.isMarkedAsVisible());
					visibilityToggle.setEnabled(true); // Works because JavaScript is single threaded...
				}
			}
		});
	}
897257
public static ClickHandler chain (final ClickHandler... handlers)
    {
        return new ClickHandler() {
            public void onClick (ClickEvent event) {
                for (ClickHandler handler : handlers) {
                    try {
                        handler.onClick(event);
                    } catch (Exception e) {
                        Console.log("Chained click handler failed", "handler", handler, e);
                    }
                }
            }
        };
    }
433461
public void add(TimelineEvent event, TimelineUpdater timelineUpdater) {
        events.add(event);

        if (timelineUpdater != null) {
            // update UI
            timelineUpdater.add(event);
        }
    }
477009
def update_webhook(self, webhook_url, webhook_id, events=None):
        """"""
        hooks = self._request(MINUT_WEBHOOKS_URL, request_type='GET')['hooks']
        try:
            self._webhook = next(
                hook for hook in hooks if hook['url'] == webhook_url)
            _LOGGER.debug("Webhook: %s", self._webhook)
        except StopIteration:  # Not found
            if events is None:
                events = [e for v in EVENTS.values() for e in v if e]
            self._webhook = self._register_webhook(webhook_url, events)
            _LOGGER.debug("Registered hook: %s", self._webhook)
            return self._webhook