Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. Hub
  2.  
  3. // Config s.t. subdomains can get, but only the root domain can set and del
  4. CrossStorageHub.init([
  5. {origin: /.example.com$/, allow: ['get']},
  6. {origin: /://(www.)?example.com$/, allow: ['get', 'set', 'del']}
  7. ]);
  8.  
  9. Client
  10.  
  11. var storage = new CrossStorageClient('https://store.example.com/hub.html');
  12.  
  13. storage.onConnect().then(function() {
  14. return storage.set('newKey', 'foobar');
  15. }).then(function() {
  16. return storage.get('existingKey', 'newKey');
  17. }).then(function(res) {
  18. console.log(res.length); // 2
  19. }).catch(function(err) {
  20. // Handle error
  21. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement