Giter Site home page Giter Site logo

brainguy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

brainguy's Issues

Different input for block shortcut method on()

Hi Avdi,

I was doing some research about this gem and I've found unexpected behavior when using the on shortcut syntax. I've expected full event as the block argument but I got only event explicit arguments (see the exampel below).

If this behavior is intentional what was decision behind it?

require 'brainguy'

class BrainguyWorker
  include Brainguy::Observable

  def call(name)
    emit(:call_success, "Called #{name}")
  end
end

class BrainguyListener
  include Brainguy::Observer

  def on_call_success(event)
    puts "Listener: #{event.inspect}"
  end
end

brain = BrainguyWorker.new
brain.events.attach BrainguyListener.new
listener = proc do |event|
  puts "Proc: #{event.inspect}"
end
brain.on(:call_success) do |event|
  puts "Block: #{event.inspect}"
end

# Output:
# Listener: #<struct Brainguy::Event name=:call_success,... args=["Called Blurb"]>
# Proc: #<struct Brainguy::Event name=:call_success,... args=["Called Blurb"]>
# Block: "Called Blurb"

Alias method #cancel on Subscription

First of all, thanks for taking the time to build this library. It's really neat and I really appreciate all effort you've put in.

Recently, I've done some work in Java using RxJava. It's a Java implementation of ReactiveX. They have named the cancellation of a subsctiption, unsubscribe. I've seen this naming for a few other libraries as well.

Naturally, I fiddled around with brainguy and tried to call #unsubscribe on the subscription. But it didn't work since it's called #cancel. I was wondering what you think about creating an alias, #unsubscribe for Subscription#cancel? It could be a nice win for others assuming the same API as with other Observer implementations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.