@@ -22,16 +22,18 @@ LegalCollection.createIndexAsync({ documentId: 1 })
2222 */
2323Meteor . publish (
2424 'freedombase:legal.getLatest' ,
25- function ( documentAbbr , language ) {
25+ async function ( documentAbbr , language ) {
2626 check ( documentAbbr , String )
2727 check ( language , Match . Maybe ( String ) )
2828 const sub = this
2929 const options = { limit : 1 , sort : { effectiveAt : - 1 } }
3030
31- const handle = LegalCollection . find (
31+ const cursor = LegalCollection . find (
3232 { documentAbbr, effectiveAt : { $lte : new Date ( ) } } ,
3333 options ,
34- ) . observeChanges ( {
34+ )
35+
36+ const handle = await cursor . observeChangesAsync ( {
3537 added ( id : string , doc : LegalDocument ) {
3638 if (
3739 language &&
@@ -92,15 +94,16 @@ Meteor.publish('freedombase:legal.getLatestTiny', (documentAbbr) => {
9294 */
9395Meteor . publish (
9496 'freedombase:legal.getAll' ,
95- function ( documentAbbr : string , language : string ) {
97+ async function ( documentAbbr : string , language : string ) {
9698 check ( documentAbbr , String )
9799 check ( language , Match . Maybe ( String ) )
98100 const sub = this
99101
100- const handle = LegalCollection . find (
102+ const cursor = LegalCollection . find (
101103 { documentAbbr } ,
102104 { sort : { effectiveAt : - 1 } } ,
103- ) . observeChanges ( {
105+ )
106+ const handle = await cursor . observeChangesAsync ( {
104107 added ( id : string , doc : LegalDocument ) {
105108 if ( language && doc . language !== language && doc . i18n ) {
106109 if ( doc . i18n [ language ] . title ) doc . title = doc . i18n [ language ] . title
@@ -136,16 +139,17 @@ Meteor.publish(
136139 */
137140Meteor . publish (
138141 'freedombase:legal.get' ,
139- function ( documentAbbr : string , version : string , language : string ) {
142+ async function ( documentAbbr : string , version : string , language : string ) {
140143 check ( documentAbbr , String )
141144 check ( version , String )
142145 check ( language , Match . Maybe ( String ) )
143146 const sub = this
144147
145- const handle = LegalCollection . find (
148+ const cursor = LegalCollection . find (
146149 { documentAbbr, version } ,
147150 { limit : 1 , sort : { effectiveAt : - 1 } } ,
148- ) . observeChanges ( {
151+ )
152+ const handle = await cursor . observeChangesAsync ( {
149153 added ( id : string , doc : LegalDocument ) {
150154 if (
151155 language &&
0 commit comments