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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@casipe/react-service-provider

v1.0.3

Published

React library sevice provider

Readme

react-lib-chat-front

aka react-service-provider

Service Provider is an asynchronous resource to an application make requests to APIs, these providers also manage the requests, retrying failed requests, and also provide a local storage cache.

The application will able to do any HTTP request and navigate to other resources without lose these request.

  • Retry failed request by number of retries
  • Retry failed request by timeout
  • Cache with TTL
  • Use Observables

Installation

npm install --save-dev @casipe/react-service-provider@latest

Pipeline status by branch

publish-legacy

N/A

publish

Build Status

publish-next

N/A


Usage

Custom service class


import { Service } from '@casipe/react-service-provider'

class FooService extends Service {
  // config service behavior
  public requestConfig = {
    retriesTimeout: 1000,
    retryDelay: 200
  }

  observableBased() {
    return this.request({
      url: this.params.API_URL_FOO,
      headers: {
        key: this.getProp('key') // prop of ServiceProvider
      }
    })
  }

  promiseBased() {
    return this.requestAsync({
      url: this.params.API_URL_FOO,
      headers: {
        key: this.getProp('key') // prop of ServiceProvider
      }
    })
  }
}
// App.jsx
import { ServiceProvider } from '@casipe/react-service-provider'
import { useConfig } from '@casipe/react-app-context'
const services = [FooService] => {
  const appContextConfig = getConfig()
  const token = '<TOKEN>'
  return (
    <ServiceProvider services={services} authorizationToken={token} config={appContextConfig}>
      <Component />
    </ServiceProvider>
  )
}
import { useObservable, useServices } from '@casipe/react-service-provider'
export const Component = () => {
  const [fooService] = useServices(FooService)
  const [foo, setFoo] = useRequest<FruitInterface[]>([])

  useEffect(() => {
    const subscriber = fooService.observableBased().subscribe( response => {
      setFoo(response)
    })
    return () => {
      subscriber.unsubscribe()
    }
  }, [])

  return (
    <div>
      {foo.isCached && 'CACHED'}
      {foo.error && <h1>{list.error?.message}</h1>}
      {foo.isLoading && <div>...loading</div>}
      {!foo.isLoading && list.data && (
        <div>{foo.data?.map(fruitItemComponent)}</div>
      )}
    </div>
  )
}

Connect to web socket

SocketIO Configuration

const App: FC = () => {
  const config = useConfig()
  const socketIo: SocketIOConfigInterface = {
    url: config.SOCKETIO_URL,
    namespaces: [USER_ID_FROM_TOKEN, MERCHANT_ID_FROM_TOKEN],
    socketIoOptions: {
      extraHeaders: { hello: 'message', Authorization: TOKEN_FROM_SESSION }
    }
  }
  return (
    <ServiceProvider
      config={config}
      services={[ChatService]}
      socketIo={socketIo} // SocketIOConfigInterface
      authorizationToken={TOKEN_FROM_SESSION}
    >{...}</ServiceProvider>
  )
}

Usage

  • This example's about an incoming chat message from WebSocket
  • The WS service doesn't send messages through socket just receive
  • Send request through REST
  • Wait response through websocket
// services/ChatService.ts
export interface ChatPayloadInterface {
  message: string
}

export class ChatService extends Service<DemoAppParams> {
  private chatSubject = new ReplaySubject<string>(Infinity)
  public chat$ = this.chatSubject.asObservable()
  public init() {
    this.socket<ChatPayloadInterface>('chat')
      .pipe(map((message) => message.payload.message))
      .subscribe(this.chatSubject)
  }
}

Solutions

  1. Messages to user and user groups, is posted to a namespace, configure these namespaces on SocketIOConfigInterface object.
  2. Use action to identify behavior in service
  3. Use payload to identify a document inside the application
  4. When you expect a message for a specific job, use the jobId method to control this flow, see an example in the demo