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

v_comet

v1.1.8

Published

real time content updater

Downloads

48

Readme

#V_Comet

contributions welcome Known Vulnerabilities

Real time content updater for React-JS and Angular

Demo

Using with react app for showing real time clock

How to install

    npm install v_comet

or

    npm i v_comet

How to use

Just only need wrap your state variable using v-comet

You can use any place in component, but we recommended initializing inside the componentDidMount method in react or ngAfterViewInit in angular and make sure to pass state variable with ' ' or " " in react. In angular just use variable with this keyword.

import { V_ } from 'v_comet';

/**
   title is the variable that need to change.
*/

V_('this.state.title', object); /** in react */

V_('this.title', object); /** in angular */

Example code:




     let object = {
       url: 'http://worldtimeapi.org/api/ip',
       this_scope: this,
       default: {datetime: 'default value'},
       time:3000
     };
     V_('this.state.title', object);
     
     

url : url that need to fetch data (default value)

this_scope : pass this key word (default value)

default : default value in need to return (optional)

We recommend to use default value , if any error return V_comet set default value to state variable. Make sure to pass default value as valid type. In this example api call return value as json type with datetime key, so we set default value as the same as return type.

time : call api end point with this time interval. If it is not defined call only when component render. (Optional)

return : you can pass your custom method as object key value to v_comet. v_comet will pass response to this method as argument and set state variable in react app with return value of this method. Make sure to create custom method to pass argument and return valid data. This is very helpful if you try get data from innerHTML value in response html.

config : config is used to pass user defined fetch api properties. this is optional variable, if this is not initialized fetch api used default value. config must be pass as object.object keys are same as fetch api in javascript. for more detail follow relevant documentation in fetch api

Example:

      let fetch_config = {
          credentials: 'same-origin', // 'include', default: 'omit'
          method: 'POST', // 'GET', 'PUT', 'DELETE', etc.
          body: JSON.stringify({name: 'V_comet'}), // Coordinate the body type with 'Content-Type'
          headers: new Headers({
              'Content-Type': 'application/json'
          }),
      };

Pass fetch properties to object as value of config key


      let fetch_config = {
          credentials: 'same-origin', // 'include', default: 'omit'
          method: 'POST', // 'GET', 'PUT', 'DELETE', etc.
          body: JSON.stringify({name: 'V_comet'}), // Coordinate the body type with 'Content-Type'
          headers: new Headers({
              'Content-Type': 'application/json'
          }),
      };

      let object = {
          url: 'http://worldtimeapi.org/api/ip',
          this_scope: this,
          default: {datetime: 'default value'},
          time:10000,
          return: this.customMethod,
          config: fetch_config
      };


      V_('this.state.title', object);

Here is how to use return option:

      let object = {
          url: 'http://worldtimeapi.org/api/ip',
          this_scope: this,
          default: {datetime: 'default value'},
          time:10000,
          return: this.customMethod
      };
      V_('this.state.title', object);
      
      customMethod(_Object) {
          return {datetime: 'custom method return value'};
      }

Support / Donations

If you want to support v_comet development, please consider donating .it helps us to keep this projects active and alive!
Paypal

Author

Ruwan Chamara
Github

Contributing

Contributions,issues and features request are welcome ! Feel free to check issues page

License

ISC License

Copyright (c) 2019, ruwan chamara ([email protected])

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.