Package kiss

Examples of kiss.Disposable


     * @return Chainable API.
     */
    public final P unsubscribe(Object subscriberOrType) {
        if (disposer != null && disposer.containsKey(subscriberOrType)) {
            // as subscriber
            Disposable unsubscriber = disposer.remove(subscriberOrType);

            if (unsubscriber != null) {
                unsubscriber.dispose();

                if (disposer.isEmpty()) {
                    disposer = null;
                }
            }
View Full Code Here


    }

    @Test
    public void registerConsumerEvent() throws Exception {
        FunctionalPubSub pubsub = new FunctionalPubSub();
        Disposable disposable = pubsub.observe(UIAction.Click).to(value -> {
            pubsub.consumeUI++;
        });

        pubsub.publish(event(UIAction.Click));
        assert pubsub.consumeUI == 1;

        pubsub.publish(event(UIAction.Click));
        assert pubsub.consumeUI == 2;

        pubsub.publish(event(UIAction.Focus));
        assert pubsub.consumeUI == 2;

        disposable.dispose();
        pubsub.publish(event(UIAction.Click));
        assert pubsub.consumeUI == 2;
    }
View Full Code Here

    @Test
    public void observe() throws Exception {
        EventEmitter<String> reciever = new EventEmitter();
        Publishable publishable = new Publishable();
        Disposable disposable = publishable.observe(String.class).to(reciever);

        publishable.publish("1");
        assert reciever.retrieve() == "1";

        disposable.dispose();
        publishable.publish("3");
        assert reciever.retrieve() == null;
    }
View Full Code Here

TOP

Related Classes of kiss.Disposable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.