Skip to content

Adds a isInitialised call to check if the BehaviorSubject is initialised #2331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Dorvaryn
Copy link

@Dorvaryn Dorvaryn commented Jan 5, 2015

Since the BehaviorSubject can be created without a default value, it could be interesting to be able to know if the subject is initialised (if it holds a value).
Adding this check allows for lazy initialisation of the behavior's value.

…sed.

Since the BehaviorSubject can be created without a default value, it is
important to be able to know if the subject is initialised (if it holds a value).
Adding this check allows for lazy initialisation of the behavior's value.
@akarnokd
Copy link
Member

akarnokd commented Jan 5, 2015

Is there a particular use case you try to solve?

@Dorvaryn
Copy link
Author

Dorvaryn commented Jan 5, 2015

I was looking at the BehaviorSubject to represent the value of some remote objects, since it caches the last value it is perfect to act as a local cache and if a refresh is triggered any observer would get the update.

Having this check would allow to use the empty construction and trigger the remote fetch only if the subject is uninitialised (first access) .

@akarnokd
Copy link
Member

Please check out #2470 for a set of Subject API changes that includes your is initialized check by the name hasValue.

@Dorvaryn
Copy link
Author

Closing this since it is addressed in a more complete way in #2470

@Dorvaryn Dorvaryn closed this Jan 21, 2015
@Dorvaryn Dorvaryn deleted the behavior_subject_initialisation_check branch January 21, 2015 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants