by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    tibuch
    @tibuch
    @tischi probably wants to join too
    Jan Kožusznik
    @kozusznik
    Christian "Tischi" Tischer
    @tischi
    @tibuch now in lobby we meet?
    tibuch
    @tibuch
    @tischi yes on my way
    Florian Jug
    @fjug
    See you!
    turekg
    @turekg
    @ bus stop
    Florian Jug
    @fjug
    We go inside
    Christian "Tischi" Tischer
    @tischi
    @tpietzsch Are you planning on coming to iti4? I would need some expert advise :-)
    tibuch
    @tibuch
    I know totally out of character, but do we have dinner plans?
    order vs going out?
    Florian Jug
    @fjug
    don’t care
    tpietzsch
    @tpietzsch
    /**
     * A variable of type {@code T}.
     * Accessible via {@link #get()} / {@link #set(Object)}.
     * Listeners
     *
     * @author Tobias Pietzsch
     */
    public class ListenableVar< T, L >
    {
        private final AtomicReference< T > ref;
    
        private final Listeners.List< L > listeners;
    
        private final BiConsumer< L, T > notify;
    
        private final boolean notifyWhenSet;
    
        public ListenableVar( final T value, final Consumer< L > notify )
        {
            this( value, notify, false );
        }
    
        public ListenableVar( final T value, final BiConsumer< L, T > notify )
        {
            this( value, notify, false );
        }
    
        public ListenableVar( final T value, final Consumer< L > notify, final boolean notifyWhenSet )
        {
            this( value, ( l, t ) -> notify.accept( l ), notifyWhenSet );
        }
    
        public ListenableVar( final T value, final BiConsumer< L, T > notify, final boolean notifyWhenSet )
        {
            this.ref = new AtomicReference<>( value );
            this.notify = notify;
            this.notifyWhenSet = notifyWhenSet;
            this.listeners = new Listeners.SynchronizedList<>();
        }
    
        public void set( final T value )
        {
            final T previous = this.ref.getAndSet( value );
            if ( notifyWhenSet || !previous.equals( value ) )
                listeners.list.forEach( l -> notify.accept( l, value ) );
        }
    
        public T get()
        {
            return ref.get();
        }
    
        public Listeners< L > listeners()
        {
            return listeners;
        }
    
        interface ChangeListener
        {
            void changed();
        }
    
        interface ValueListener< T >
        {
            void valueChanged( T value );
        }
    
        public static void main( String[] args )
        {
            {
                ListenableVar< Integer, ChangeListener > var = new ListenableVar<>( 1, ChangeListener::changed );
                var.listeners().add( () -> System.out.println( "value changed" ) );
                var.set( 10 );
                System.out.println( "var = " + var.get() );
            }
    
            {
                ListenableVar< Integer, ValueListener< Integer > > var = new ListenableVar<>( 1, ValueListener::valueChanged );
                var.listeners().add( v -> System.out.println( "value changed to " + v ) );
                var.set( 10 );
                System.out.println( "var = " + var.get() );
            }
        }
    }
    Florian Jug
    @fjug
    its sunday… maybe going out?
    Emil Melnikov
    @emilmelnikov
    You could try the reactive approach, if that's applicable to your problem: http://reactivex.io/
    tpietzsch
    @tpietzsch
    @emilmelnikov thanks for the pointer
    do you use this?
    Emil Melnikov
    @emilmelnikov
    No, haven't had a chance, but it's very popular in GUI applications (Android at least).
    Apparently, there is also https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Flow.html. Requires Java >= 9 though...
    tpietzsch
    @tpietzsch
    @emilmelnikov ah, I remember reading a bit of http://www.reactive-streams.org/ (referenced in the Flow javadoc)
    that is definitely interesting stuff
    arghhhh... so much to do, so little time
    Florian Jug
    @fjug
    @/all Food plans?
    I’m torn between staying and surviving… :wink:
    turekg
    @turekg
    Whatever u decide I will join you
    tibuch
    @tibuch
    I am eating 🥐
    Florian Jug
    @fjug
    9:15 in the lobby
    turekg
    @turekg
    I am brooding haha
    Florian Jug
    @fjug
    brooding?
    Is 9:15 ok for you?
    turekg
    @turekg
    Yeah that’s fine ta
    @emilmelnikov kool stuff I have no used Observers in ages this is even niftier
    @fjug finishing up http://www.brotopiabook.com/
    tibuch
    @tibuch
    @turekg we are on our way now (according to florians Italian side)
    Petr Bainar
    @PetrBainar
    The most convenient bus stop for going to the train station: https://en.mapy.cz/s/3mwgP
    tibuch
    @tibuch
    So almost
    Petr Bainar
    @PetrBainar
    Take the line no 37 to the stop Svinov nádraží
    Vladimír Ulman
    @xulman
    I'll come later today to it4i -- waiting for my wife to return earlier from her work to switch duties, kid is ill (thank you Mr. Murphy, very helpful this time again)
    @janaklimova can you please pick up my lunch (I guess I have ordered one) and bring back in a box?
    Vladimír Ulman
    @xulman
    @kozusznik I'm available via Skype, if needed...
    janaklimova
    @janaklimova
    @xulman Will do ;)
    Florian Jug
    @fjug
    Let me guess... I’m waiting in the lobby for no one to come, don’t I?
    Guess will join you soon then... :wink:
    tibuch
    @tibuch
    When should we head for lunch?
    about 20min?
    Jan Kožusznik
    @kozusznik
    @xulman I will stay home today after weekend hacking.
    Vladimír Ulman
    @xulman
    aha :) OK
    Florian Jug
    @fjug
    Help! Need my card!
    Im locked in the staircase!
    Ok... Tim came back...