{"action":"created","issue":{"url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/339","repository_url":"https://api.github.com/repos/Esri/arcgis-rest-js","labels_url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/339/labels{/name}","comments_url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/339/comments","events_url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/339/events","html_url":"https://github.com/Esri/arcgis-rest-js/issues/339","id":364169945,"node_id":"MDU6SXNzdWUzNjQxNjk5NDU=","number":339,"title":"facilitate composition of our low level functional API to reduce end user friction","user":{"login":"tomwayson","id":662944,"node_id":"MDQ6VXNlcjY2Mjk0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/662944?v=4","gravatar_id":"","url":"https://api.github.com/users/tomwayson","html_url":"https://github.com/tomwayson","followers_url":"https://api.github.com/users/tomwayson/followers","following_url":"https://api.github.com/users/tomwayson/following{/other_user}","gists_url":"https://api.github.com/users/tomwayson/gists{/gist_id}","starred_url":"https://api.github.com/users/tomwayson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomwayson/subscriptions","organizations_url":"https://api.github.com/users/tomwayson/orgs","repos_url":"https://api.github.com/users/tomwayson/repos","events_url":"https://api.github.com/users/tomwayson/events{/privacy}","received_events_url":"https://api.github.com/users/tomwayson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-26T19:10:30Z","updated_at":"2018-09-26T19:52:02Z","closed_at":null,"author_association":"MEMBER","body":"One area of friction with our functional approach is that sometimes multiple requests that are sequential or at least made w/in the same context will share parameters that will need passed into each fn call. For example, when working w/ a feature service, you may want to call [queryFeatures](https://esri.github.io/arcgis-rest-js/api/feature-service/queryFeatures/), [getFeature](https://esri.github.io/arcgis-rest-js/api/feature-service/queryFeatures/), and the [getAttachments](https://esri.github.io/arcgis-rest-js/api/feature-service/getAttachments/) in succession, all w/ the same `url` (and maybe the same `authentication`).\r\n\r\nAn OO solution would be to add `new FeatureService({ url })` that would expose methods that wrap the stateless functions passing in `this.url` to each. I'm pretty sure none of us (least of all @dbouwman)  want to get into that business due to the risk of memory leaks etc associated w/`new`ing up instances in browsers.\r\n\r\nInstead, I propose we provide at least an example somewhere of how to use functional techniques like higer order functions to compose our low level functional API and reduce the above friction. For example: \r\n\r\n```js\r\nimport { queryFeatures, getFeature } from '@esri/arcgis-rest-feature-service';\r\n\r\n// create functions to query the trees service\r\nconst treesUrl = 'https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0';\r\nconst queryTrees = withUrl(treesUrl, queryFeatures);\r\nconst getTree = withUrl(treesUrl, getFeature);\r\n```\r\n\r\nHere's a working JSBin w/ what I have in mind: https://jsbin.com/geravah/edit?html,js,console\r\n\r\nI think the question for me is where to include this information? A guide topic w/ a linked JSBin? Or would we go so far to include common helpers like `withUrl()` and/or `withAuthentication()` in the libraries? If so, in what package?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/comments/424847424","html_url":"https://github.com/Esri/arcgis-rest-js/issues/339#issuecomment-424847424","issue_url":"https://api.github.com/repos/Esri/arcgis-rest-js/issues/339","id":424847424,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDg0NzQyNA==","user":{"login":"tomwayson","id":662944,"node_id":"MDQ6VXNlcjY2Mjk0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/662944?v=4","gravatar_id":"","url":"https://api.github.com/users/tomwayson","html_url":"https://github.com/tomwayson","followers_url":"https://api.github.com/users/tomwayson/followers","following_url":"https://api.github.com/users/tomwayson/following{/other_user}","gists_url":"https://api.github.com/users/tomwayson/gists{/gist_id}","starred_url":"https://api.github.com/users/tomwayson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomwayson/subscriptions","organizations_url":"https://api.github.com/users/tomwayson/orgs","repos_url":"https://api.github.com/users/tomwayson/repos","events_url":"https://api.github.com/users/tomwayson/events{/privacy}","received_events_url":"https://api.github.com/users/tomwayson/received_events","type":"User","site_admin":false},"created_at":"2018-09-26T19:52:02Z","updated_at":"2018-09-26T19:52:02Z","author_association":"MEMBER","body":"Or do we only provide a `withOptions(commonRequestOptions, fn)` that would work at least on any fn that has only a single requestOptions argument?\r\n"}}
{"actor":{"display_login":"tomwayson"}}