Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More initiatives #3

Merged
merged 4 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Initiatives package

[Unreleased]: https://github.com/ArcGIS/hub.js/compare/v0.0.1...HEAD
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@

### Example

```js
import { helloHub } from '@esri/hub-request';
```bash
npm install @esri/hub-initiatives
```

```js
import { getInitiative } from '@esri/hub-initiatives';

helloHub()
.then(response => {
console.log(response) // dummy data from a sample server
})
// pass in an initiative id
getInitiative("abc123")
.then(
response => // get back initiative metadata
);
```

### API Reference
Expand All @@ -64,15 +68,27 @@ Some useful commands include:

### Packages

* [`@esri/hub-request`](./packages/request/) - Underpins other packages and supports making low-level requests.
* [`@esri/hub-common-types`](./packages/common-types) - Typescript typings we reuse.
* [`@esri/hub-initiatives`](./packages/initiatives) - Helper functions for working with Initiatives.

### Design Philosophy

`hub.js` is designed as a set of data manipulation functions, not persistent objects with behavior. You should not use `new` in conjunction with this library. Just include the modules your application needs and use them to hide lower-level abstractions for making API calls for hub related things. Your application should manage the state of the data you receive from these methods.

This project builds on the packages in [`arcgis-rest-js`](https://esri.github.io/arcgis-rest-js), so if you want even lower-level access, you can also use them directly.

#### Why Not Objects?

Persistent objects often introduce memory leaks in JavaScript applications. As soon as you instantiate a `new` object, you need to consider it's lifespan. If you happen to assign that object inside a closure or somewhere else long-lived, you might end up with references that can not be destroyed by the garbage collector. Creating clean separation between _functions-that-fetch-or-manipulate-data_ and _application-state-as-a-javascript-object_ helps to avoid this problem.

Thus, this library does _not_ attempt to mirror [`hub-py`](https://github.com/esridc/hub-py) in API structure or capabilities.

[More about Javascript Memory Leaks](https://auth0.com/blog/four-types-of-leaks-in-your-javascript-code-and-how-to-get-rid-of-them/)

### Frequently Asked Questions

* [Is this a _supported_ Esri product?](docs/FAQ.md#is-this-a-supported-esri-product)
* [How does this project compare with the ArcGIS API for JavaScript?](docs/FAQ.md#comparison-with-the-arcgis-api-for-javascript)
* [Is this similar to the ArcGIS API for Python?](docs/FAQ.md#comparison-with-the-arcgis-api-for-python)
* [Why TypeScript?](docs/FAQ.md#why-typescript) What if I prefer [VanillaJS](https://stackoverflow.com/questions/20435653/what-is-vanillajs)?
* [Why TypeScript?](docs/FAQ.md#why-typescript) What if I prefer [Vanilla.js](https://stackoverflow.com/questions/20435653/what-is-vanillajs)?

### Issues

Expand Down
13 changes: 0 additions & 13 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ It is not. We offer no guarantees, SLAs, nor a product lifecycle to support plan

This project is an open source collaboration between developers from a variety of teams at Esri that was initially developed to scratch an itch of our own. That said, we are actively recruiting outside contributors and fully expect that the tools here will be useful to a subset of our customers.

## Comparison with the ArcGIS API for JavaScript

The ArcGIS API for JavaScript is Esri's flagship product for building web applications to visualize, edit, map and analyze geospatial data. It is a feature complete client side API for working with the REST services based ArcGIS platform.
The ArcGIS API for JavaScript includes significant client side functionality including smart mapping, 3D rendering, geometric analysis and feature editing as well as full support for working with web maps and web scenes.

The goal of this project on the other hand is to provide a convenient binding to the underlying REST API for those who need to work directly with it from JavaScript. This project includes functional equivalents of the low-level request methods and identity management in the ArcGIS API for JavaScript, along with additional thin wrappers to assist developers in scripting against the ArcGIS REST API directly in Node.js and browser applications that do _not_ incorporate a map.

We aim to make interacting with the platform as intuitive as possible, but the surface area of the project currently does not nearly encompass the entire ArcGIS REST API.

## Comparison with the ArcGIS API for Python

This project is similar to the ArcGIS API for Python in many ways. Like the ArcGIS API for Python, this library aims to be a scripting tool that simplifies interacting with the ArcGIS REST API, but where the ArcGIS API for Python highlights integration with dataframes and Jupyter Notebooks for visualization and sharing this project provides only generic tools for JavaScript applications running on a server, CLI, in a browser or as a script.

## Why TypeScript

Using TypeScript allows us to add type information to request params and response structures. This vastly simplifies development. TypeScript also has excellent support for newer `async`/`await` patterns and for generating API documentation with [TypeDoc](http://typedoc.org/).
Expand Down
23 changes: 12 additions & 11 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,36 @@ module.exports = function(config) {
exclude: [],

karmaTypescriptConfig: {
reports: {
lcovonly: "coverage",
html: "coverage",
text: ""
},
// reports: {
// lcovonly: "coverage",
// html: "coverage",
// text: ""
// },
compilerOptions: {
module: "commonjs"
},
tsconfig: "./tsconfig.json",
bundlerOptions: {
transforms: [require("karma-typescript-es6-transform")()],
exclude: ["@esri/arcgis-rest-common-types"],
resolve: {
// karmas resolver cant figure out the symlinked deps from lerna
// so we need to manually alias each package here.
alias: fs
.readdirSync("packages")
.filter(p => p[0] !== ".")
.reduce((alias, p) => {
alias[`@esri/${p}`] = `packages/${p}/src/index.ts`;
alias[`@esri/hub-${p}`] = `packages/${p}/src/index.ts`;
return alias;
}, {})
}
}
},

coverageReporter: {
type: 'lcov',
dir: 'coverage/'
},
// coverageReporter: {
// type: 'lcov',
// dir: 'coverage/'
// },

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
Expand All @@ -57,7 +58,7 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["jasmine-diff", "dots", "karma-typescript", "coverage", "coveralls"],
reporters: ["jasmine-diff", "dots", "karma-typescript"/*, "coverage", "coveralls"*/],

// web server port
port: 9876,
Expand Down
Loading