Skip to content

Commit 266c330

Browse files
authored
Merge pull request #3 from robotpy/master
Updating fork
2 parents 5f554b7 + 0de8a6b commit 266c330

File tree

4 files changed

+39
-14
lines changed

4 files changed

+39
-14
lines changed

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
---
22
language: python
3+
python:
4+
- "3.6"
35
services:
46
- docker
57

68
install:
7-
- pip install sphinx sphinx-rtd-theme
9+
- pip install sphinx sphinx-rtd-theme black
810

911
script:
1012
- make -C docs html
13+
- black --check --diff .
1114
- ./build_exe.sh
1215

13-
jobs:
14-
include:
15-
- stage: format-check
16-
python:
17-
- "3.6"
18-
install:
19-
- pip install black
20-
script:
21-
- black --check --diff .
22-
2316
deploy:
2417
- provider: pypi
2518
user: $PYPI_USERNAME

build_exe.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
cd $(dirname $0)
7-
docker run --rm -v "$(pwd):/src:Z" -e PYTHONPATH=/src cdrx/pyinstaller-windows:python2
8-
docker run --rm -v "$(pwd):/src:Z" --entrypoint /bin/bash cdrx/pyinstaller-windows:python2 -c "chown -R $(id -u $USERNAME) /src/dist"
7+
docker run --rm -v "$(pwd):/src:Z" -e PYTHONPATH=/src cdrx/pyinstaller-windows:python3
8+
docker run --rm -v "$(pwd):/src:Z" --entrypoint /bin/bash cdrx/pyinstaller-windows:python3 -c "chown -R $(id -u $USERNAME) /src/dist"
99

1010
zip dist/pynetworktables2js-$(git describe --tags).zip dist/windows/pynetworktables2js.exe

pynetworktables2js/js/networktables.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,21 @@ var NetworkTables = new function () {
112112
that indicates whether the websocket is connected
113113
:param immediateNotify: If true, the function will be immediately called
114114
with the current status of the websocket
115+
:returns: a function that will unsubscribe
115116
*/
116117
this.addWsConnectionListener = function(f, immediateNotify) {
117118
connectionListeners.push(f);
118119

119120
if (immediateNotify == true) {
120121
f(socketOpen);
121122
}
123+
124+
return function() {
125+
const index = connectionListeners.indexOf(f);
126+
if (index !== -1) {
127+
connectionListeners.splice(index, 1);
128+
}
129+
}
122130
};
123131

124132
/**
@@ -130,13 +138,21 @@ var NetworkTables = new function () {
130138
that indicates whether the robot is connected
131139
:param immediateNotify: If true, the function will be immediately called
132140
with the current robot connection state
141+
:returns: a function that will unsubscribe
133142
*/
134143
this.addRobotConnectionListener = function(f, immediateNotify) {
135144
robotConnectionListeners.push(f);
136145

137146
if (immediateNotify == true) {
138147
f(robotConnected);
139148
}
149+
150+
return function() {
151+
const index = robotConnectionListeners.indexOf(f);
152+
if (index !== -1) {
153+
robotConnectionListeners.splice(index, 1);
154+
}
155+
}
140156
}
141157

142158
/**
@@ -146,6 +162,7 @@ var NetworkTables = new function () {
146162
for entry, value: value of entry, isNew: If true, the entry has just been created
147163
:param immediateNotify: If true, the function will be immediately called
148164
with the current value of all keys
165+
:returns: a function that will unsubscribe
149166
*/
150167
this.addGlobalListener = function(f, immediateNotify) {
151168
globalListeners.push(f);
@@ -155,6 +172,13 @@ var NetworkTables = new function () {
155172
f(k, v, true);
156173
});
157174
}
175+
176+
return function() {
177+
const index = globalListeners.indexOf(f);
178+
if (index !== -1) {
179+
globalListeners.splice(index, 1);
180+
}
181+
}
158182
};
159183

160184
/**
@@ -165,6 +189,7 @@ var NetworkTables = new function () {
165189
for entry, value: value of entry, isNew: If true, the entry has just been created
166190
:param immediateNotify: If true, the function will be immediately called
167191
with the current value of the specified key
192+
:returns: a function that will unsubscribe
168193
*/
169194
this.addKeyListener = function(key, f, immediateNotify) {
170195
var listeners = keyListeners.get(key);
@@ -180,6 +205,13 @@ var NetworkTables = new function () {
180205
f(key, v, true);
181206
}
182207
}
208+
209+
return function() {
210+
const index = keyListeners.get(key).indexOf(f);
211+
if (index !== -1) {
212+
keyListeners.get(key).splice(index, 1);
213+
}
214+
}
183215
};
184216

185217
/**

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
tornado>=4.0
2-
pynetworktables>=2018.2.0
2+
pynetworktables>=2019.0.0

0 commit comments

Comments
 (0)