Skip to content

Commit baa541b

Browse files
committed
feat: refactor to use a single callback
1 parent 4c48333 commit baa541b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/Capabilities/SmartButtonStateController.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ FSTR(BUTTONSTATE, longPress); // Long press state value
1515
FSTR(BUTTONSTATE, setSmartButtonState); // Set state action name
1616

1717
// Callback type definitions for different button press events
18-
using SmartButtonSinglePressCallback = std::function<bool(const String &)>;
19-
using SmartButtonDoublePressCallback = std::function<bool(const String &)>;
20-
using SmartButtonLongPressCallback = std::function<bool(const String &)>;
18+
using SmartButtonPressCallback = std::function<bool(const String &)>;
2119

2220
/**
2321
* @brief Controller class for managing smart button state and interactions
@@ -37,19 +35,19 @@ class SmartButtonStateController {
3735
* @brief Register callback for single press event from app
3836
* @param cb Callback function to handle single press
3937
*/
40-
void onSinglePress(SmartButtonSinglePressCallback cb);
38+
void onSinglePress(SmartButtonPressCallback cb);
4139

4240
/**
4341
* @brief Register callback for double press event from app
4442
* @param cb Callback function to handle double press
4543
*/
46-
void onDoublePress(SmartButtonDoublePressCallback cb);
44+
void onDoublePress(SmartButtonPressCallback cb);
4745

4846
/**
4947
* @brief Register callback for long press event from app
5048
* @param cb Callback function to handle long press
5149
*/
52-
void onLongPress(SmartButtonLongPressCallback cb);
50+
void onLongPress(SmartButtonPressCallback cb);
5351

5452
protected:
5553
/**
@@ -60,9 +58,9 @@ class SmartButtonStateController {
6058
bool handleSmartButtonStateController(SinricProRequest &request);
6159

6260
private:
63-
SmartButtonSinglePressCallback smartButtonSinglePressCallback;
64-
SmartButtonDoublePressCallback smartButtonDoublePressCallback;
65-
SmartButtonLongPressCallback smartButtonLongPressCallback;
61+
SmartButtonPressCallback smartButtonSinglePressCallback;
62+
SmartButtonPressCallback smartButtonDoublePressCallback;
63+
SmartButtonPressCallback smartButtonLongPressCallback;
6664

6765
/**
6866
* returns true if states match, false otherwise
@@ -85,17 +83,17 @@ SmartButtonStateController<T>::SmartButtonStateController() {
8583
}
8684

8785
template <typename T>
88-
void SmartButtonStateController<T>::onSinglePress(SmartButtonSinglePressCallback cb) {
86+
void SmartButtonStateController<T>::onSinglePress(SmartButtonPressCallback cb) {
8987
smartButtonSinglePressCallback = cb;
9088
}
9189

9290
template <typename T>
93-
void SmartButtonStateController<T>::onDoublePress(SmartButtonDoublePressCallback cb) {
91+
void SmartButtonStateController<T>::onDoublePress(SmartButtonPressCallback cb) {
9492
smartButtonDoublePressCallback = cb;
9593
}
9694

9795
template <typename T>
98-
void SmartButtonStateController<T>::onLongPress(SmartButtonLongPressCallback cb) {
96+
void SmartButtonStateController<T>::onLongPress(SmartButtonPressCallback cb) {
9997
smartButtonLongPressCallback = cb;
10098
}
10199

0 commit comments

Comments
 (0)