Method: Optimizely::NotificationCenter#remove_notification_listener

Defined in:
lib/optimizely/notification_center.rb

#remove_notification_listener(notification_id) ⇒ Boolean

Removes previously added notification callback

Parameters:

  • notification_id

Returns:

  • (Boolean)

    true if found and removed, false otherwise



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/optimizely/notification_center.rb', line 83

def remove_notification_listener(notification_id)
  unless notification_id
    @logger.log Logger::ERROR, 'Notification ID can not be empty.'
    return nil
  end
  @notifications.each_key do |key|
    @notifications[key].each do |notification|
      if notification_id == notification[:notification_id]
        @notifications[key].delete(notification_id: notification_id, callback: notification[:callback])
        return true
      end
    end
  end
  false
end