@@ -197,4 +197,47 @@ pubnub.unsubscribe({
197197pubnub . unsubscribe ( {
198198 channelGroups : [ "demo_group1" , "demo_group2" ] ,
199199} ) ;
200- // snippet.end
200+ // snippet.end
201+
202+ {
203+ // snippet.subscriptionSetFrom2IndividualSubscriptions
204+ // create a subscription from a channel entity
205+ const channel = pubnub . channel ( 'channel_1' )
206+ const subscription1 = channel . subscription ( { receivePresenceEvents : true } ) ;
207+
208+ // create a subscription from a channel group entity
209+ const channelGroup = pubnub . channelGroup ( 'channelGroup_1' )
210+ const subscription2 = channelGroup . subscription ( ) ;
211+
212+ // add 2 subscriptions to create a subscription set
213+ const subscriptionSet = subscription1 . addSubscription ( subscription2 ) ;
214+
215+ // add another subscription to the set
216+ const subscription3 = pubnub . channel ( 'channel_3' ) . subscription ( { receivePresenceEvents : false } ) ;
217+ subscriptionSet . addSubscription ( subscription3 ) ;
218+
219+ // remove a subscription from a subscription set
220+ subscriptionSet . removeSubscription ( subscription3 ) ;
221+
222+ subscriptionSet . subscribe ( ) ;
223+ // snippet.end
224+ }
225+
226+ {
227+ // snippet.SubscriptionSetFrom2Sets
228+ // create a subscription set with multiple channels
229+ const subscriptionSet1 = pubnub . subscriptionSet ( { channels : [ 'ch1' , 'ch2' ] } ) ;
230+
231+ // create a subscription set with multiple channel groups and options
232+ const subscriptionSet2 = pubnub . subscriptionSet ( {
233+ channels : [ 'ch1' , 'ch2' ] ,
234+ subscriptionOptions : { receivePresenceEvents : true }
235+ } ) ;
236+
237+ // create a new subscription set from 2 sets
238+ const subscriptionSet3 = subscriptionSet1 . addSubscriptionSet ( subscriptionSet2 ) ;
239+
240+ // you can also remove sets
241+ const subscriptionSetWithChannelsOnly = subscriptionSet3 . removeSubscriptionSet ( subscriptionSet2 ) ;
242+ // snippet.end
243+ }
0 commit comments