question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use source loader-factory

See original GitHub issue

Hello @ghettovoice,

I hope you are fine. I am updating vuelayers. I was using 0.11.5-beta.8. In that version, the method loader-factory had a parameter which was the source, but now this is not the case anymore.

How should it be used now? This was my code, in which you can see I used the URL from the source:

loaderFactory(vm) {
                return (extent, resolution, projection) => {
                    let url = vm.$source.getUrl()
                    if (typeof url === 'function') {
                        url = url(extent, resolution, projection)
                    }
                    if (!url) {
                        return []
                    }
                    return fetch(url, {
                        credentials: 'same-origin',
                        mode: 'cors',
                    }).then(response => response.text())
                        .then(async text => {
                            if (!vm.$source) {
                                return []
                            }
                            // Some extra things I did for offline mode were here using the url
                            return vm.$source.getFormat().readFeatures(text, {
                                featureProjection: vm.viewProjection,
                                dataProjection: vm.resolvedDataProjection,
                            })
                        })
                        .catch(async error => {
                            // Some extra things I did for offline mode were here using the url
                            return vm.$source.getFormat().readFeatures(text, {
                                featureProjection: vm.viewProjection,
                                dataProjection: vm.resolvedDataProjection,
                            })
                        })
                }
            },

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghettovoicecommented, Mar 4, 2020

In this case each source should use it’s own loader factory with enclosed context variables. I would make this like this:

this.layers = ['http://example.com', 'http://example2.com'].forEach(url => {
  return {
    url,
    loaderFactory: () => (extent, resolution, projection) => {
      return fetch(url).then(...)
    }
  }
})

Then int template

<vl-layer-vector v-for="layer in layers">
  <vl-source-vector :loader-factory="layer.loaderFactory" />
</vl-layer-vector>

I don’t actually know how you add layers/source on the map. I guess you load layers configuration from somewhere and then adds them with v-for

0reactions
stale[bot]commented, May 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Document in the `loaderFactory` in the docs · Issue #9 - GitHub
While perusing the docs, I noticed that the loaderFactory static method is not documented in the batchLoader docs.
Read more >
tensorflow::serving::CachingManager::LoaderFactory Class ...
Creates servable data consisting of the loader corresponding to the servable-id. GetServableVersion(const string & servable_name, ...
Read more >
Enabling cache loaders and cache writers - IBM
You can use a CacheLoader to fetch data from an external source to cache. ... Example 2: Use a loader factory --> <backingMap...
Read more >
jsonLoader.go - external/github.com/xeipuuv/gojsonschema - Git at ...
New creates a new JSON loader for the given source. New(source string) JSONLoader. } // DefaultJSONLoaderFactory is the default JSON loader factory.
Read more >
5.3. Table Loader Factory Classes
File Loader Factory¶ ... TableFileLoaderFactory(source, encoding=None)[source]¶. Parameters ... Built with Sphinx using a theme provided by Read the Docs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found