Questions tagged [subject]

394 questions
434
votes
10 answers

What is the difference between Subject and BehaviorSubject?

I'm not clear on the difference between a Subject and a BehaviorSubject. Is it just that a BehaviorSubject has the getValue() function?
Mike Jerred
  • 9,551
  • 5
  • 22
  • 42
128
votes
4 answers

How to create Gmail filter searching for text only at start of subject line?

We receive regular automated build messages from Jenkins build servers at work. It'd be nice to ferret these away into a label, skipping the inbox. Using a filter is of course the right choice. The desired identifier is the string [RELEASE] at the…
KomodoDave
  • 7,239
  • 10
  • 60
  • 92
74
votes
4 answers

How to set a mail Subject in UIActivityViewController?

I want to set subject for email sharing in UIActivityViewController and also want to share in Twitter. I know in Twitter if we want to share — we need compress text to 140 chars. I checked many SO solutions, but nothing is working. Is this issue…
Femina
  • 1,239
  • 1
  • 12
  • 25
24
votes
1 answer

What is the difference between the isStopped and closed property of the Subject class?

The class Subject has 2 properties closed and isStopped. I know that closed can be used to check whether the Subject can still be subscribed to, but what should isStopped be used for exactly? I am asking this because I am trying to find a way to…
Maurice
  • 6,698
  • 9
  • 47
  • 104
23
votes
2 answers

Angular2 Observable BehaviorSubject service not working

I'm trying to create my own observable service but after i get the initial data from the service, any updates to the service aren't propagated to any subscribers. Service looks like this: import { Injectable } from '@angular/core'; import {…
kjoetools
  • 528
  • 1
  • 6
  • 12
19
votes
4 answers

Subject.next not firing in ngOnInit

Does anyone know why this code (initializing a value from Subject) does not work? Is there a bug or by design? What am I doing wrong? ts import { Component, OnInit } from '@angular/core'; import { Subject } from "rxjs"; @Component({ selector:…
user776686
  • 7,933
  • 14
  • 71
  • 124
18
votes
1 answer

How to add link in subject of email (gmail)

Is there a way to add link in subject of email? Following is the example of YouTube - Here in my code I'm trying the following but still unsatisfactory result. The below code is sending the subject as it is with printing the whole anchor tag in the…
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47
16
votes
2 answers

RXJS - Angular - unsubscribe from Subjects

As described in this thread, 'official' solution to unsubscribe from Observables in Angular 5+ in general is using takeUntil. So far, so good. My question is, does this also apply if the Observable I am subscribed to is actually a Subject?
didgewind
  • 524
  • 1
  • 3
  • 10
15
votes
1 answer

Error 'takeUntil is not a function' on all my Observables

For some reason I can't use the takeUntil method on any of my observables. My IDE (Visual Studio Code) shows it as a valid method while I'm coding, and it compiles fine (from typescript), but when I run it I get takeUntil is not a function on any…
WillyC
  • 3,917
  • 6
  • 35
  • 50
15
votes
4 answers

What are RxJS Subject's and the benefits of using them?

I found the rxJS docs define them as What is a Subject? An RxJS Subject is a special type of Observable that allows values to be multicasted to many Observers. While plain Observables are unicast (each subscribed Observer owns an independent…
garrettmac
  • 8,417
  • 3
  • 41
  • 60
15
votes
2 answers

How to avoid the use of Subjects in RX

So I keep reading everywhere that use of Subject is "bad" - and I kind of agree with the reasoning. However, I am trying to think of the best way to avoid using it and have an example. Currently I have an abstract class for my persisted…
Cheetah
  • 13,785
  • 31
  • 106
  • 190
14
votes
4 answers

Unit test Angular 2 service subject

I'm trying to write a test for an angular service which has a Subject property and a method to call .next() on that subject. The service is the following: @Injectable() export class SubjectService { serviceSubjectProperty$: Subject = new…
crdevdeu
  • 503
  • 1
  • 5
  • 15
14
votes
1 answer

How to create subject ( rx.js) with 2 parameters?

I am using service with subject as communication service for components in my angular2 application. Calling method: this.notification.create('test'); Service: export class NotificationService { private static notificationSource = new…
John Doe
  • 3,794
  • 9
  • 40
  • 72
13
votes
2 answers

Property 'connect' does not exist on type 'Observable' | RXJS multicast

I have an Observable that produce the unicast value(individually for all observers). But when i am going to convert into multicast using RxJs multicast operators then it return the following error. Property 'connect' does not exist on type…
Sachin Kumar
  • 3,001
  • 1
  • 22
  • 47
12
votes
2 answers

How to delay next(value) on subject?

My AlertService has private subject = new Subject();. I want to autocratically clear alert after 5 seconds. I can do it with using setTimeout() like this: autoClear(alertId?: string) { setTimeout( () => this.subject.next(new…
Xalion
  • 623
  • 9
  • 27
1
2 3
26 27