You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,6 +14,28 @@ you are saving on `localStorage` which you then use to update your UI through ev
14
14
* Ember CLI v4.4 or above
15
15
* Node.js v14 or above
16
16
17
+
## Modern Implementation
18
+
19
+
As of version 3.0.0, the `master-tab-factory` service has been updated to use native ES6 class syntax for better performance, security, and maintainability:
20
+
21
+
***Native class syntax** - Uses modern `class` syntax instead of `Service.extend()`
***Reactive `isMasterTab` property** - Uses `@tracked` decorator for automatic template updates when master tab status changes
24
+
***Full backward compatibility** - All existing APIs remain unchanged and work with both classic and native class patterns
25
+
26
+
The examples in this README use **native class syntax** (Ember Octane style), which is the recommended approach for modern Ember applications. The service works seamlessly with both classic and native class implementations in your application.
27
+
28
+
### Automatic Reactivity
29
+
30
+
The `isMasterTab` property is now decorated with `@tracked`, which means templates automatically re-render when the master tab status changes:
31
+
32
+
```hbs
33
+
{{!-- This will automatically update when master tab status changes --}}
34
+
<p>Is this the master tab? <strong>{{#if this.masterTab.isMasterTab}}Yes{{else}}No{{/if}}</strong></p>
35
+
```
36
+
37
+
When a tab loses or gains master status (e.g., when the master tab closes), any template or computed property referencing `this.masterTab.isMasterTab` will automatically update without requiring manual property observation or `set()` calls. This provides a seamless reactive experience with Ember's auto-tracking system.
38
+
17
39
## Notes
18
40
19
41
* The service ensures that only one master tab exists at any one time.
@@ -37,48 +59,58 @@ You can clone this repository and have a look at the dummy app to see it in acti
37
59
38
60
```js
39
61
// services/server-time-run.js
40
-
importEmberfrom'ember';
41
-
42
-
exportdefaultEmber.Service.extend({
43
-
masterTab:Ember.inject.service(),
44
-
currentTime:null,
45
-
init() {
46
-
this._super(...arguments);
47
-
window.addEventListener('storage', e=> { // only slave tabs will receive this event
0 commit comments