@inglorious/web 6.0.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "6.0.1",
3
+ "version": "6.0.2",
4
4
  "description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -6,22 +6,6 @@
6
6
 
7
7
  const NO_WATCH_ID = null
8
8
 
9
- /**
10
- * Stops an active geolocation watch.
11
- * @param {GeolocationEntity} entity - The geolocation entity.
12
- */
13
- export function unwatch(entity) {
14
- const geolocation = getGeolocation()
15
-
16
- if (entity.watchId !== NO_WATCH_ID && geolocation) {
17
- geolocation.clearWatch(entity.watchId)
18
- }
19
-
20
- entity.isLoading = false
21
- entity.isWatching = false
22
- entity.watchId = NO_WATCH_ID
23
- }
24
-
25
9
  /**
26
10
  * Initializes the geolocation entity with default state.
27
11
  * @param {GeolocationEntity} entity - The geolocation entity.
@@ -64,10 +48,11 @@ export function request(entity, options = {}, api) {
64
48
 
65
49
  entity.isSupported = Boolean(geolocation)
66
50
  entity.error = null
51
+ const entityId = entity.id
67
52
 
68
53
  if (!geolocation) {
69
54
  entity.isLoading = false
70
- api.notify(`#${entity.id}:error`, createUnsupportedError())
55
+ api.notify(`#${entityId}:error`, createUnsupportedError())
71
56
  return
72
57
  }
73
58
 
@@ -75,10 +60,10 @@ export function request(entity, options = {}, api) {
75
60
 
76
61
  geolocation.getCurrentPosition(
77
62
  (position) => {
78
- api.notify(`#${entity.id}:success`, normalizePosition(position))
63
+ api.notify(`#${entityId}:success`, normalizePosition(position))
79
64
  },
80
65
  (error) => {
81
- api.notify(`#${entity.id}:error`, error)
66
+ api.notify(`#${entityId}:error`, error)
82
67
  },
83
68
  options,
84
69
  )
@@ -95,6 +80,22 @@ export function success(entity, position) {
95
80
  entity.position = position
96
81
  }
97
82
 
83
+ /**
84
+ * Stops an active geolocation watch.
85
+ * @param {GeolocationEntity} entity - The geolocation entity.
86
+ */
87
+ export function unwatch(entity) {
88
+ const geolocation = getGeolocation()
89
+
90
+ if (entity.watchId !== NO_WATCH_ID && geolocation) {
91
+ geolocation.clearWatch(entity.watchId)
92
+ }
93
+
94
+ entity.isLoading = false
95
+ entity.isWatching = false
96
+ entity.watchId = NO_WATCH_ID
97
+ }
98
+
98
99
  /**
99
100
  * Starts watching geolocation changes.
100
101
  * @param {GeolocationEntity} entity - The geolocation entity.
@@ -106,10 +107,11 @@ export function watch(entity, options = {}, api) {
106
107
 
107
108
  entity.isSupported = Boolean(geolocation)
108
109
  entity.error = null
110
+ const entityId = entity.id
109
111
 
110
112
  if (!geolocation) {
111
113
  entity.isLoading = false
112
- api.notify(`#${entity.id}:error`, createUnsupportedError())
114
+ api.notify(`#${entityId}:error`, createUnsupportedError())
113
115
  return
114
116
  }
115
117
 
@@ -121,10 +123,10 @@ export function watch(entity, options = {}, api) {
121
123
  entity.isWatching = true
122
124
  entity.watchId = geolocation.watchPosition(
123
125
  (position) => {
124
- api.notify(`#${entity.id}:success`, normalizePosition(position))
126
+ api.notify(`#${entityId}:success`, normalizePosition(position))
125
127
  },
126
128
  (error) => {
127
- api.notify(`#${entity.id}:error`, error)
129
+ api.notify(`#${entityId}:error`, error)
128
130
  },
129
131
  options,
130
132
  )