redd icon indicating copy to clipboard operation
redd copied to clipboard

Add ability to stream messages.

Open avinashbot opened this issue 8 years ago • 1 comments
trafficstars

Requested in https://redd.it/76rrw4.

Is it possible to stream comment replies? e.g.:

session.my_messages(:category=>'comments').stream { |comment| .. }

Thanks in advance.

EDIT: It looks like PRAW supports it (see here). I wonder if it would be possible to duplicate this functionality in Redd.

avinashbot avatar Oct 26 '17 17:10 avinashbot

Reply by OP (for keeping track):

This seems to be working. Let me know if I'm on the right track!

options = { :category=>'unread' }.freeze
Redd::Models::PaginatedListing.new(SESSION.client, options) do |**req_options|
  SESSION.my_messages(options.merge(req_options))
end.stream do |comment|
  next unless comment.instance_of?(Redd::Models::Comment)

  # ..
end

avinashbot avatar Nov 02 '17 14:11 avinashbot