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

@visit-x/vxunread-messages

v2.0.2

Published

This npm package represents the core unread messages functionality for a client. The number of unread messages from a certain model or from all client's models will come as a property after integrating this library into your project. This value will be li

Downloads

4

Readme

SUMMARY

This npm package represents the core unread messages functionality for a client. The number of unread messages from a certain model or from all client's models will come as a property after integrating this library into your project. This value will be live, updating itself event-based.

The project "vxunread-messages" is completely isolated from other Campoint softwares that implement the messaging between a client and a model. For instance, "vxmessenger". They can co-exist in any application due to their technical independence.

TECHNICAL DOCUMENTATION

The only exported element from the library is an high-order componenent, which will send to the wrapped component the property "unreadMessages" of type number with the desired value. The initial/default value is going to be 0.

The high-order component will receive only one argument, the wrapped component. This component for receiving the unread messages will have to give in its props, the "connection" property, which will contain the login and communication information between the client and the model.

interface Connection {
    partner?: {
        id: string; // The the model's platform's ID - for instance vx-models or vxpages.
        key: string; // The model's ID
    };
    webToken: string; // client's webToken for the login process
    userKey: string; // client's userKey for the login process
    onError: (error: { code: number, reason: string }) => void; // a function for dealing with any back-end error
}

If no partner is set in connection property, the "unreadMesssages" property will be of type Array<{ unreadMessages: number, partner: { id: string, key: string}}> and will contain the unread messages for all the models that interacted at some point with our client (the client has a channel already created).

Example

import withUnreadMessages from '@visit-x/vxunread-messages';

const UnreadMessagesDisplayer = (props: Props) => (
    <div>Unread messages from your specified model: {props.unreadMessages}</div>
);

const UnreadMessages = withUnreadMessages(UnreadMessagesDisplayer);

const connection = {
    userKey:"888888",
    webToken:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1Njc0MjgwNDYsInBhcnRuZXJUeXBlIjoiY3AiLCJwYXJ0bmVySWQiOjgxNzAsInJvbGVJZCI6MTAwMDAsImd1ZXN0SWQiOjg1NTE2MjUsInVzZXJQb29sSWQiOjgxNzAsInBmbUlkIjoxNTAzLCJwZm1TdWJyZWYiOiIifQ.NppVfb1bIDLHuq4HTAmEeYPn2EIIRDVEZsSSH1PrAK0",
    partner: {
        id: "8320",
        key: "8470922"
    },
    onError: (error) => { console.log(`Error's reason is ${error.reason}`); }
};

render() {
    return (
        <UnreadMessages connection={connection} />
    );
}

'''