Skip to content

AhmedTarekHasan/ObservableSubjectsInJavaScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

The Right Way to Create Observable Subjects in JavaScript

A best practice on how to define your Subjects in JavaScript objects.


While working on your cool JavaScript project, you might need to implement a service which manages a stream of data. In this case, the first thing pops up into your mind is using Observables or Subjects.


You can do this using libraries like Rxjs or you can even implement it yourself as I showed you before on my article How to Use Observables with Vanilla JavaScript. No frameworks used, just pure vanilla JavaScript.


Either ways, at the end you would need to wrap a Subject inside your service object. However, there are more than one way to do it.


In this article, we would get introduced to a Best Practice on how to implement this.


If you are interested into reading more about this topic, you can read the rest of the article.


If you want to support me:

▶ Subscribe to Medium using my referral link
▶ Subscribe to Medium Newsletter
▶ Subscribe to LinkedIn Newsletter
▶ Follow me on Medium
▶ Follow me on Twitter
▶ Follow me on LinkedIn


Authors: