Skip to content

Commit a7da97d

Browse files
committed
Document how to hot reload
1 parent ad35749 commit a7da97d

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
# Requirements
33

4-
~~~
4+
~~~ bash
55
pip install asyncio
66
pip install websockets
77
~~~
88

99
Currently requires some "observable collections", with modifications (just local import "from .stuff import Thing".
1010

11-
~~~
11+
~~~ bash
1212
git clone https://github.com/fousteris-dim/Python-observable-collections.git observablecollections
1313
patch -d observablecollections/ < 0001-Local-imports.patch
1414
~~~
@@ -19,14 +19,42 @@ And for some better styling of some examples you might want to download picnicss
1919
wget https://raw.githubusercontent.com/franciscop/picnic/master/picnic.min.css -O lib/picnic.min.css
2020
~~~
2121

22-
# Helper
22+
# Helpers
2323

24-
(bash)
25-
~~~
26-
pvue() { (sleep .5;firefox ${1%.*}.html)& python3 ${1%.*}.py;}
24+
### Simply launch python and open a browser (firefox) at the right address.
2725

26+
~~~ bash
27+
# bash function
28+
pvue() { (sleep .5;firefox ${1%.*}.html)& python3 ${1%.*}.py;}
29+
30+
# examples
2831
pvue example-1
2932
pvue example-1.
3033
pvue example-1.html
3134
pvue example-1.py
3235
~~~
36+
37+
38+
### OR, to develop with auto-reload.
39+
40+
~~~ bash
41+
# one-time install
42+
pip install watchdog
43+
npm install -g simple-hot-reload-server
44+
45+
46+
# in terminal 1 (hot html reload, for all files)
47+
hrs .
48+
49+
# in terminal 2 (start and restart python
50+
pvue() { if test "$1" = open ; then shift ; (sleep 1 ; firefox "http://localhost:8082/${1%.*}.html") & fi; watchmedo auto-restart --patterns="*.py" --ignore-patterns="*/.#*.py" bash -- -c '(sleep .250 ; touch '"${1%.*}"'.html) & python3 '"${1%.*}"'.py' ; }
51+
pvue open example-1
52+
pvue example-1
53+
# the first opens firefox initially
54+
~~~
55+
56+
57+
# TODO
58+
59+
- make components working (more than a single top level one, or make it easy to pass linked-state to js components)
60+
- have a clean solution for the observable collections (integrate and clean minimal code or find another lib)

0 commit comments

Comments
 (0)