github centrifugal/centrifuge-js 2.7.0

latest releases: 5.2.2, 5.2.1, 5.2.0...
3 years ago
  • add missing offset to TS definitions for PublicationContext, note that seq and gen fields considered deprecated and will go away with next major centrifuge-js release
  • add top-level methods: history, presence, presenceStats – those are useful when using sever-side subscriptions
  • fix wrong error format of top-level publish Promise reject branch – it now contains protocol error object (with code and message fields)
  • possibility to set name and version protocol fields over Centrifuge config options
  • remove unused promise option from configuration
  • add history iteration API (usage limited to Centrifuge library for Go at the moment) - see example below
  • subscribe success event context in positioned subscriptions (added in Centrifuge library v0.15.0) now contains streamPosition object (with current offset and epoch fields)
  • updated protobuf-js dependency (now ^6.10.2)
  • all dev-dependencies updated and now use the latest versions of webpack, babel, eslint, mocha etc
  • internal code refactoring of Subscrption methods - code is simplified and more reusable now

Let's look at history pagination feature in more detail. It's now possible to iterate over channel history this way:

resp = await subscription.history({'since': {'offset': 2, 'epoch': 'xcf4w'}, limit: 100});

If server can't fulfill a query for history (due to stream retention - size or expiration, or malformed offset, or stream already has another epoch) then an Unrecoverable Position Error will be returned (code 112).

To only call for current offset and epoch use:

resp = await subscription.history({limit: 0});

I.e. not providing since and using zero limit.

Due to backward compatibility history call without arguments will return full existing history in channel (though it's possible to limit max number of publications to return on server side).

For now history pagination feature only works with Centrifuge library based server and not available in Centrifugo.

Don't miss a new centrifuge-js release

NewReleases is sending notifications on new releases.