SlideShare a Scribd company logo
Observer Design Pattern in Java
"Define a one-to-many dependency between objects so that when one
object changes state, all its dependents are notified and updated
automatically".
You can think of observer design pattern in two ways
Subject-Observer relationship:Object which is being observed is refereed as
Subject and classes which observe subject are called Observer
Publisher-Subscriber relationship:A publisher is one who publish data and
notifies it to the list of subscribers who have subscribed for the same to that
publisher. A simple example is Newspaper. Whenever a new edition is
published by the publisher,it will be circulated among subscribers whom
have subscribed to publisher.
The observers will not monitor every time whether there is any change in
state of subject or not, since they will be notified for every state change of
subject, until they stop observing subject.
Some real life examples:
You might have surfed "Flipkart.com-Online megastore".So when you
search for any product and it is unavailable then there is option called
"Notify me when product is available".If you subscribe to that option
then when state of product changes i.e. it is available,you will get
notification mail "Product is available now you can buy it".In this
case,Product is subject and You are an observer.
• Lets say,your permanent address is changed then you need to notify
passport authority and pan card authority.So here passport authority
and pan card authority are observers and You are a subject.
• On facebook also,If you subscribe someone then whenever new
updates happen then you will be notified.
When to use it:
• When one object changes its state,then all other dependents object
must automatically change their state to maintain consistency
• When subject doesn't know about number of observers it has.
• When an object should be able to notify other objects without
knowing who objects are.
UML diagram for observer design pattern:
Components:
Subject
Knows its observers
Has any number of observer
Provides an interface to attach and detaching observer object at run
time
Observer
Provides an update interface to receive signal from subject
ConcreteSubject
Stores state of interest to ConcreteObserver objects.
Send notification to it's observer
ConcreteObserver
Maintains reference to a ConcreteSubject object
Maintains observer state consistent with subjects.
Implements update operation
Java in-built API for observer pattern:
• The java API provides one class and one inteface for implementing
observer pattern.
• 1. java.util.Observable-class
• 2. java.util.Observer-interfac
java.util.Observable:
For being observed,class must extend this class. The subclass becomes
observable and override methods of java.util.Observable and other objects
can "observe" changes in state of this object.
Methods:
addObserver(Observer o) :add Observer to the list of observers for this
subject.
deleteObserver(Observer o) :delete Observers from the list of observers .
notifyObservers() : notify all the observers if object has changed.
hasChanged() :return true if object has changed.
setChanged() :This method marks object has changed
clearChanged() :this method will indicate that subject has no changes or all
the observers has been notified.
java.util.Observer:
The class that performs the "observing" must implement the
java.util.Observer interface. There is a single method:
public void update(Observable obj, Object arg) :This method is called
whenever the observed object is changed. An application calls an
Observable object's notifyObservers method for notifying to all the
observers of change.
Example:
You might have surfed "Flipkart.com-Online megastore".So
when you search for any product and it is unavailable then
there is option called "Notify me when product is
available".If you subscribe to that option then when state of
product changes i.e. it is available,you will get notification
mail "Product is available now you can buy it".
Observer pattern

More Related Content

Similar to Observer pattern

pattern v
pattern vpattern v
pattern v
ValerieMiguel3
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
Observer pattern
Observer patternObserver pattern
Observer pattern
Somenath Mukhopadhyay
 
Design patterns
Design patternsDesign patterns
Design patternsISsoft
 
Observer dp
Observer dpObserver dp
Observer dpISsoft
 
Angular 2.0 change detection
Angular 2.0 change detectionAngular 2.0 change detection
Angular 2.0 change detection
Ran Wahle
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android Montréal
Sidereo
 
Intro to Rx Java
Intro to Rx JavaIntro to Rx Java
Intro to Rx Java
Syed Awais Mazhar Bukhari
 
Scope.js prsentation
Scope.js prsentationScope.js prsentation
Scope.js prsentation
Atishay Baid
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptx
ShantanuDharekar
 
Strange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveXStrange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveX
Matthew Will
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryguestebd714
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryachraf_ing
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
Fábio Bernardo
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
Netesh Kumar
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
Rahul Malhotra
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
Maxim Volgin
 

Similar to Observer pattern (20)

pattern v
pattern vpattern v
pattern v
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
 
Sdp
SdpSdp
Sdp
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Observer dp
Observer dpObserver dp
Observer dp
 
Angular 2.0 change detection
Angular 2.0 change detectionAngular 2.0 change detection
Angular 2.0 change detection
 
RxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android MontréalRxJava pour Android : présentation lors du GDG Android Montréal
RxJava pour Android : présentation lors du GDG Android Montréal
 
Intro to Rx Java
Intro to Rx JavaIntro to Rx Java
Intro to Rx Java
 
Scope.js prsentation
Scope.js prsentationScope.js prsentation
Scope.js prsentation
 
Unit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptxUnit 5 Activity and Activity Life Cycle.pptx
Unit 5 Activity and Activity Life Cycle.pptx
 
Strange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveXStrange Async Code - ReaxtiveX
Strange Async Code - ReaxtiveX
 
Tarefapatterns
TarefapatternsTarefapatterns
Tarefapatterns
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
The 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summaryThe 23 gof design patterns in java ,the summary
The 23 gof design patterns in java ,the summary
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
RxJava 2 Reactive extensions for the JVM
RxJava 2  Reactive extensions for the JVMRxJava 2  Reactive extensions for the JVM
RxJava 2 Reactive extensions for the JVM
 
JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
 

More from anshu_atri

Types of input and output devices
Types of input and output devicesTypes of input and output devices
Types of input and output devices
anshu_atri
 
Types of computers
Types of computersTypes of computers
Types of computers
anshu_atri
 
Intro of computers
Intro of computersIntro of computers
Intro of computers
anshu_atri
 
Examination process (1)
Examination process (1)Examination process (1)
Examination process (1)
anshu_atri
 
Iterator pattern
Iterator patternIterator pattern
Iterator pattern
anshu_atri
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
anshu_atri
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
anshu_atri
 
Generic programming in java
Generic programming in javaGeneric programming in java
Generic programming in java
anshu_atri
 
Acem web designing
Acem web designingAcem web designing
Acem web designing
anshu_atri
 
Super and final in java
Super and final in javaSuper and final in java
Super and final in java
anshu_atri
 
Aravali college of engg. and management
Aravali college of engg. and managementAravali college of engg. and management
Aravali college of engg. and management
anshu_atri
 

More from anshu_atri (11)

Types of input and output devices
Types of input and output devicesTypes of input and output devices
Types of input and output devices
 
Types of computers
Types of computersTypes of computers
Types of computers
 
Intro of computers
Intro of computersIntro of computers
Intro of computers
 
Examination process (1)
Examination process (1)Examination process (1)
Examination process (1)
 
Iterator pattern
Iterator patternIterator pattern
Iterator pattern
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
 
Generic programming in java
Generic programming in javaGeneric programming in java
Generic programming in java
 
Acem web designing
Acem web designingAcem web designing
Acem web designing
 
Super and final in java
Super and final in javaSuper and final in java
Super and final in java
 
Aravali college of engg. and management
Aravali college of engg. and managementAravali college of engg. and management
Aravali college of engg. and management
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

Observer pattern

  • 2. "Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically". You can think of observer design pattern in two ways Subject-Observer relationship:Object which is being observed is refereed as Subject and classes which observe subject are called Observer Publisher-Subscriber relationship:A publisher is one who publish data and notifies it to the list of subscribers who have subscribed for the same to that publisher. A simple example is Newspaper. Whenever a new edition is published by the publisher,it will be circulated among subscribers whom have subscribed to publisher. The observers will not monitor every time whether there is any change in state of subject or not, since they will be notified for every state change of subject, until they stop observing subject.
  • 3. Some real life examples: You might have surfed "Flipkart.com-Online megastore".So when you search for any product and it is unavailable then there is option called "Notify me when product is available".If you subscribe to that option then when state of product changes i.e. it is available,you will get notification mail "Product is available now you can buy it".In this case,Product is subject and You are an observer. • Lets say,your permanent address is changed then you need to notify passport authority and pan card authority.So here passport authority and pan card authority are observers and You are a subject. • On facebook also,If you subscribe someone then whenever new updates happen then you will be notified.
  • 4. When to use it: • When one object changes its state,then all other dependents object must automatically change their state to maintain consistency • When subject doesn't know about number of observers it has. • When an object should be able to notify other objects without knowing who objects are.
  • 5. UML diagram for observer design pattern:
  • 6. Components: Subject Knows its observers Has any number of observer Provides an interface to attach and detaching observer object at run time Observer Provides an update interface to receive signal from subject
  • 7. ConcreteSubject Stores state of interest to ConcreteObserver objects. Send notification to it's observer ConcreteObserver Maintains reference to a ConcreteSubject object Maintains observer state consistent with subjects. Implements update operation
  • 8. Java in-built API for observer pattern: • The java API provides one class and one inteface for implementing observer pattern. • 1. java.util.Observable-class • 2. java.util.Observer-interfac
  • 9. java.util.Observable: For being observed,class must extend this class. The subclass becomes observable and override methods of java.util.Observable and other objects can "observe" changes in state of this object. Methods: addObserver(Observer o) :add Observer to the list of observers for this subject. deleteObserver(Observer o) :delete Observers from the list of observers . notifyObservers() : notify all the observers if object has changed. hasChanged() :return true if object has changed. setChanged() :This method marks object has changed clearChanged() :this method will indicate that subject has no changes or all the observers has been notified.
  • 10. java.util.Observer: The class that performs the "observing" must implement the java.util.Observer interface. There is a single method: public void update(Observable obj, Object arg) :This method is called whenever the observed object is changed. An application calls an Observable object's notifyObservers method for notifying to all the observers of change.
  • 11. Example: You might have surfed "Flipkart.com-Online megastore".So when you search for any product and it is unavailable then there is option called "Notify me when product is available".If you subscribe to that option then when state of product changes i.e. it is available,you will get notification mail "Product is available now you can buy it".