mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-02 01:18:04 +08:00
docs(observer): fix subject name in the example
This commit is contained in:
committed by
André Costa
parent
8340d100e3
commit
8003908e9f
@@ -11,7 +11,7 @@ Overview
|
|||||||
|
|
||||||
.. _observer pattern: https://en.wikipedia.org/wiki/Observer_pattern
|
.. _observer pattern: https://en.wikipedia.org/wiki/Observer_pattern
|
||||||
|
|
||||||
The ``lv_observer`` module is an implemention of the `Observer Pattern`_.
|
The ``lv_observer`` module is an implementation of the `Observer Pattern`_.
|
||||||
|
|
||||||
This implementation consists of:
|
This implementation consists of:
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ A typical use case looks like this:
|
|||||||
* some_module.c
|
* some_module.c
|
||||||
*--------------*/
|
*--------------*/
|
||||||
|
|
||||||
extern lv_subject_t some_subject;
|
extern lv_subject_t my_subject;
|
||||||
|
|
||||||
// Will be called when Subject's value changes
|
// Will be called when Subject's value changes
|
||||||
static void some_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
|
static void some_observer_cb(lv_observer_t * observer, lv_subject_t * subject)
|
||||||
@@ -81,19 +81,19 @@ A typical use case looks like this:
|
|||||||
void some_module_init(void)
|
void some_module_init(void)
|
||||||
{
|
{
|
||||||
// Subscribe to Subject as an Observer.
|
// Subscribe to Subject as an Observer.
|
||||||
lv_subject_add_observer(&some_subject, some_observer_cb, NULL);
|
lv_subject_add_observer(&my_subject, some_observer_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------
|
/*--------------
|
||||||
* some_system.c
|
* some_system.c
|
||||||
*--------------*/
|
*--------------*/
|
||||||
|
|
||||||
extern lv_subject_t some_subject;
|
extern lv_subject_t my_subject;
|
||||||
|
|
||||||
void some_event(void)
|
void some_event(void)
|
||||||
{
|
{
|
||||||
// The below call sets Subject's value to 30 and notifies current Observers.
|
// The below call sets Subject's value to 30 and notifies current Observers.
|
||||||
lv_subject_set_int(&some_subject, 30);
|
lv_subject_set_int(&my_subject, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ both unsubscribes it from the Subject and deletes it from the LVGL heap.
|
|||||||
Subscribing While Associating Observer with a Widget
|
Subscribing While Associating Observer with a Widget
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The function below assocates a Widget with an Observer while subscribing to a
|
The function below associates a Widget with an Observer while subscribing to a
|
||||||
Subject. A copy of the pointer to that Widget is saved in the Observer's ``target``
|
Subject. A copy of the pointer to that Widget is saved in the Observer's ``target``
|
||||||
field. This works exactly like the above method except that when the Widget is
|
field. This works exactly like the above method except that when the Widget is
|
||||||
deleted, the Observer thus created will be automatically unsubscribed from the
|
deleted, the Observer thus created will be automatically unsubscribed from the
|
||||||
|
|||||||
Reference in New Issue
Block a user