npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hoodie-plugin-global-share

v3.0.0

Published

Hoodie.js Global Share Plugin

Downloads

15

Readme

Build Status

Hoodie Global Share Plugin

Make selected objects publically accessible via hoodie.global store methods.

Installation

hoodie install global-share

Usage

The Global Share Plugin extends all promises returned by hoodie.store methods with two additional functions: publish and unpublish.

// publish all my todos
hoodie.store.findAll('task').publish()

// unpublish specific note
hoodie.store.find('note', 'abc1234').unpublish()

All objects marked as public are accessible (read-only) via the hoodie.global API

// list all public tasks
hoodie.global.findAll('task').then(showAllPublicTasks)

// update list of tasks on change
hoodie.global.on('task:change', handleTaskChange)

Full Frontend API

add / remove own objects from the public global store

// publish / unpublish can be called on all promises
// return by any hoodie.store method.
promise = hoodie.store.add(type, attributes).publish()
promise = hoodie.store.find(type, id).publish()
promise = hoodie.store.findOrAdd(type, id, attributes).publish()
promise = hoodie.store.findAll(/* type */).publish()
promise = hoodie.store.update(type, id, changedAttributes).publish()
promise = hoodie.store.updateAll(/* type, */ changedAttributes).publish()
promise = hoodie.store.remove(type, id).publish()
promise = hoodie.store.removeAll(/* type */).publish()

// it works the same on scoped stores
promise = hoodie.store(type).find(id).unpublish()
promise = hoodie.store(type, id).update(changedAttributes).publish()

// publish / unpublish return own promises that only resolve
// if the objects were published successfully on the server
promise.then(handlePublishSuccess, handleStoreOrPublishError);

access objects from / listen to changes in the public global store

// hoodie.global has all read-only methods from hoodie.store,
// with the same footprint
promise = hoodie.global.find(type, id)
promise = hoodie.global.findAll(/* type */)

// you can listen on changes as well
hoodie.global.on('add', handleNewObject)
hoodie.global.on('task:change', handleChangedTask)
hoodie.global.on('task:123:remove', handleTask123Removed)

How it works internally

The plugin's worker creates a new database hoodie-plugin-global-share that all objects from all user databases that are marked as public are replicated to.

Calling .publish() on a store method in the frontend adds a $public: true flag to the respecitve objects, that is used by the filtered replications from user databases → hoodie-plugin-global-share database.

Calling .unpublish() uses the hoodie.task API internally to start globalshareunpublish task with object types/IDs to be unpublished. The task gets picked up by the worker which then removes all objects with the passed types/IDs from the hoodie-plugin-global-share database.

Contributing

We love contributors <3 If you need any help getting started, please don't hesitate to get in touch at any time.

For Questions/Bug reports specific to the Global Share Plugin:
https://github.com/hoodiehq/hoodie-plugin-global-share/issues/new

For more generic questions to Hoodie Architecture etc. https://github.com/hoodiehq/discussion/issues/new

If you want to send pull requests, please make sure to add according tests. Run tests with

grunt

License & Copyright

Copyright 2012-2014 https://github.com/hoodiehq/ and other contributors
Licensed under the Apache License 2.0.