Skip to content

Commit 0ea20f9

Browse files
committed
devops: add circleci
1 parent 9461fd5 commit 0ea20f9

File tree

6 files changed

+85
-17
lines changed

6 files changed

+85
-17
lines changed

.circleci/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
# specify the version you desire here
10+
- image: circleci/node:8
11+
12+
working_directory: ~/repo
13+
14+
steps:
15+
- checkout
16+
17+
# Download and cache dependencies
18+
- restore_cache:
19+
keys:
20+
- v1-dependencies-{{ checksum "package.json" }}
21+
# fallback to using the latest cache if no exact match is found
22+
- v1-dependencies-
23+
24+
- run: npm install
25+
26+
- save_cache:
27+
paths:
28+
- node_modules
29+
key: v1-dependencies-{{ checksum "package.json" }}
30+
31+
# run tests!
32+
- run: npm run test

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ Realtime Geolocation with Firestore & RxJS
44

55
[Live Demo](https://geo-test-c92e4.firebaseapp.com)
66

7-
## QuickStart
7+
<p align="center">
8+
9+
<a href="https://slackin-pbfjhfxnsa.now.sh"><img src="https://slackin-pbfjhfxnsa.now.sh/badge.svg"></a>
10+
11+
<!-- <a href="https://circleci.com/gh/codediodeio/angular-firestarter"><img src="https://circleci.com/gh/codediodeio/angular-firestarter.svg?style=svg"></a> -->
12+
13+
</p>
14+
15+
## :checkered_flag: QuickStart
816

917
```shell
1018
npm install firebase geofirex
@@ -55,7 +63,7 @@ query.subscribe(console.log);
5563
// [{ ...documentData, queryMetadata: { distance: 1.23232, bearing: 230.23 } }]
5664
```
5765

58-
## API
66+
## :notebook: API
5967

6068
### `collection(path: string, query? QueryFn)`
6169

@@ -114,7 +122,7 @@ Example: `const point = geo.point(38, -119)`
114122
- `point.distance(latitude, longitude)` Haversine distance to a point
115123
- `point.bearing(latitude, longitude)` Haversine bearing to a point
116124

117-
## Tips
125+
## :zap: Tips
118126

119127
### Seeing this error: `DocumentReference.set() called with invalid data`
120128

integration/src/app/basic-geoquery/basic-geoquery.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ agm-map {
1515
button {
1616
display: block;
1717
margin-top: 10px
18+
}
19+
20+
@media (max-width: 960px) {
21+
.tools {
22+
position: fixed;
23+
top: 0;
24+
background: #fff;
25+
padding: 10px;
26+
left: 0;
27+
height: 100vh;
28+
width: 20vw;
29+
overflow-y: scroll;
30+
}
1831
}

integration/src/app/realtime-geoquery/realtime-geoquery.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@ button {
2020
.doc {
2121
font-weight: 1.2em;
2222
font-weight: bold;
23+
}
24+
25+
@media (max-width: 960px) {
26+
.tools {
27+
position: fixed;
28+
top: 0;
29+
background: #fff;
30+
padding: 10px;
31+
left: 0;
32+
height: 100vh;
33+
width: 20vw;
34+
overflow-y: scroll;
35+
}
2336
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "geofirex",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Realtime Firestore GeoQueries with RxJS",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.esm.js",
@@ -14,7 +14,7 @@
1414
"url": "https://github.com/codediodeio/geofirex.git"
1515
},
1616
"scripts": {
17-
"test": "jest --coverage",
17+
"test": "jest --coverage --forceExit",
1818
"test:watch": "jest --watchAll",
1919
"build": "rollup -c",
2020
"dev": "rollup -c -w",

src/collection.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export interface GeoQueryOptions {
1313
}
1414
const defaultOpts: GeoQueryOptions = { units: 'km' };
1515

16+
export interface QueryMetadata {
17+
bearing: number;
18+
distance: number;
19+
}
20+
21+
export interface GeoQueryDocument {
22+
[key: string]: any;
23+
queryMetadata: QueryMetadata;
24+
}
25+
1626
export class GeoFireCollectionRef {
1727
private ref: firestore.CollectionReference;
1828
private query: firestore.Query;
@@ -72,7 +82,7 @@ export class GeoFireCollectionRef {
7282
* @param {string} id document id
7383
* @param {Latitude} latitude
7484
* @param {Longitude} longitude
75-
* @param {string='point'} field optional field to set data to
85+
* @param {string} field optional name of the document property, defaults to 'point'
7686
* @returns {Promise<void>}
7787
*/
7888
setPoint(
@@ -103,14 +113,14 @@ export class GeoFireCollectionRef {
103113
* @param {number} radius the radius to search from the centerpoint
104114
* @param {string} field the document field that contains the GeoFirePoint data
105115
* @param {GeoQueryOptions} opts=defaultOpts
106-
* @returns {Observable<any>}
116+
* @returns {Observable<GeoQueryDocument>}
107117
*/
108118
within(
109119
center: GeoFirePoint,
110120
radius: number,
111121
field: string,
112122
opts = defaultOpts
113-
) {
123+
): Observable<GeoQueryDocument[]> {
114124
const precision = setPrecsion(radius);
115125
const centerHash = center.hash.substr(0, precision);
116126
const area = GeoFirePoint.neighbors(centerHash).concat(centerHash);
@@ -180,17 +190,9 @@ function snapToData(id = 'id') {
180190
}
181191

182192
/**
183-
internal use only
193+
internal, do not use
184194
*/
185195
function createStream(input): Observable<any> {
186-
// return Observable.create(observer => {
187-
// input.onSnapshot({
188-
// next(val) {
189-
// observer.next(val);
190-
// }
191-
// });
192-
// });
193-
194196
return new Observable(observer => {
195197
const unsubscribe = input.onSnapshot(observer);
196198
return { unsubscribe };

0 commit comments

Comments
 (0)