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

feathers-mithril

v2.1.0

Published

Connect feathers.js to mithril.js

Downloads

5

Readme

feathers-mithril

Connect feathers.js to mithril.js

Installation

Just run npm install --save feathers-mithril. You'll also need feathers-reactive in your project to use advanced sync functionality.

To add to your client, just add it like you would any other feathers plugin:

var m = require('mithril');
var stream = require('mithril/stream')
var fm = require('feathers-mithril');
// ...a bit of code later...
var app = feathers()
  .configure(feathers.socketio(socket))
  .configure(feathers.hooks())
  .configure(reactive(rxjs)) // you'll need this call to feathers-reactive for sync to work
  .configure(fm(m, stream))
  // followed by more app.configure calls here

Basic Usage

It’s really easy! Feathers service calls return combined prop-promises, just like m.request does. See below:

var result = catService.find();

// Results can be used like usual, as a promise.
result.then(function (data) {
  // do something with data
});

// Or if you're feeling fancy, use a result as a prop instantly!
// The initial value is undefined.
result() // => returns undefined

// But! After the feathers calls loads, the prop value is set,
// and mithril will rerender with the updated data
setTimeout(function() {
   result() // => returns array of results
}, 3000);

This feature allows you to pass results directly into views and use them immediately, provided the views can handle undefined prop values.

Syncing

Although create , get , list , patch , remove , and a few other service functions all return these fancy hybrid prop-promises, there’s a special function on the props returned by get and list .

var result = catService.get({id: 123});

result.sync(true);

result() // => returns undefined
// ...some time later after the initial load...
result() // => returns {id: 123, name: "Fluffums"}
// ...after another user edits the fluffums object...
result() // => returns {id: 123, name: "Fluffums 2"}

That’s right, the prop will automatically update (and the view will rerender) whenever the server info changes!

There is an important caviat, which is you must call .sync(false) on the prop in the destructor of the component that called .sync(true) , otherwise we’ll get nasty memory leaks.