2.7.0
- add missing
offset
to TS definitions forPublicationContext
, note thatseq
andgen
fields considered deprecated and will go away with next majorcentrifuge-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 (withcode
andmessage
fields) - possibility to set
name
andversion
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 currentoffset
andepoch
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.