Skip to content

Instantly share code, notes, and snippets.

@jredville
Forked from mattpodwysocki/notification.rb
Last active August 29, 2015 13:56
Show Gist options
  • Save jredville/8793614 to your computer and use it in GitHub Desktop.
Save jredville/8793614 to your computer and use it in GitHub Desktop.
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
module RX
module Notification
class << self
def create_on_next(value)
OnNextNotification.new value
end
def create_on_error(error)
# TODO
end
def create_on_completed
# TODO
end
end
end
# Represents an on_next notification to an observer.
class OnNextNotification
# this may not be needed, this doesn't create the create_on_*
# methods on OnNextNotification. If you want that, then you should
# use a included hook, or make those methods normal module methods and
# extend instead of include
include Notification
attr_reader :value, :kind
def initialize(value)
@value = value
@kind = :on_next
end
def has_value?
true
end
def ==(other)
o.class == self.class && @kind == other.kind && @value == other.value
end
alias_method :eql?, :==
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment