awulder / angular-prismicio

AngularJS service for prismic.io
MIT License
32 stars 15 forks source link

Make angular-prismic able to change access token on the fly #20

Open magnusart opened 10 years ago

magnusart commented 10 years ago

Hi

Since the Prismic service caches the Api and Context with maybeApi and maybeContex there is no clear way to effectively change the accessToken except in app.config() with the PrismicProvider object.

This means we have to do a full page reload/redirect when editors and publishers want to view different versions.

To be clear, while it is possible to use Prismic.setAccessToken() and also Prismic.configuration but when retrieving the context or api we get the cached with the old access token.

Suggestion, when using any of the setAccessToken etc. methods, make the maybeApi and maybeContext is cleared. So that the next request will fetch fresh data. I would also suggest broadcasting something.

If you think this is a good idea I can implement it.

magnusart commented 10 years ago

By the way, the same would go for a good way of changing the ref (which is picked up from the url the first time maybeApi and maybeCtx is loaded).