0

「Sidekiq」を使用して、特定の時間にタスクに関するリマインダーをスケジュールしています。その作業は完璧です。今、私はそれを追加して自分のナビゲーションバーに通知したいと思っています。そのため、「プライベートパブ」を使用してリマインダーメッセージを公開しています。これが Sidekiq Worker のコードです。

class ReminderWorker
include Sidekiq::Worker

def perform(args)
 reminder = Reminder.find(args['id'])
 reminder.activate = true
 PrivatePub.publish_to("reminder", message: reminder)
 reminder.save
 end
end

「application.js」内でテストにアラートを使用していますが、機能していません。

 PrivatePub.subscribe("reminder", function(data, channel) {
 return alert('Remarks ='+ data.message.remarks);

});

何か不足していますか?Ryan http://railscasts.com/episodes/316-private-pub?autoplay=trueに従って rb ファイルのプライベート パブを介してデータを公開することが可能であるため

4

1 に答える 1

0

This gem has been updated last time three years ago and seems not maintained. Maybe it's better to use newest rails solution like ActionCabble? https://github.com/rails/rails/tree/master/actioncable

I found this issue, that proofs that ActionCabble can be integrated to ActiveJob or other background workers:

https://github.com/rails/rails/issues/22897

于 2016-04-20T15:37:26.527 に答える