Skip to content

Instantly share code, notes, and snippets.

@Stradivario
Last active July 28, 2019 17:46
Show Gist options
  • Save Stradivario/817028d190d651652e0e61fcc64cda93 to your computer and use it in GitHub Desktop.
Save Stradivario/817028d190d651652e0e61fcc64cda93 to your computer and use it in GitHub Desktop.
Reactive advanced architecture programming with @rxdi/core and rxjs
import { setup } from '@rxdi/core';
import { switchMap } from 'rxjs/operators';
import { combineLatest } from 'rxjs';
setup({
services: [
{
provide: 'gosho',
lazy: true,
useFactory: async () => 'yey'
}
]
})
.pipe(
switchMap(ctx =>
combineLatest(
setup({
services: [
{
provide: 'pesho',
useFactory: () => ctx.get('gosho')
}
]
}),
setup({
services: []
}),
setup({
services: []
}),
setup({
services: []
})
)
)
)
.subscribe(ctx => {
console.log(ctx.get('pesho'));
});
@Stradivario
Copy link
Author

Stradivario commented Jul 27, 2019

import { setup } from '@rxdi/core';
import { switchMap } from 'rxjs/operators';
import { combineLatest } from 'rxjs';

setup({
  services: [
    {
      provide: 'gosho',
      lazy: true,
      useFactory: async () => 'yey'
    }
  ]
})
  .pipe(
    switchMap(ctx =>
      combineLatest(
        setup({
          services: [
            {
              provide: 'pesho',
              useFactory: () => ctx.get('gosho')
            }
          ]
        }),
        setup({
          services: []
        }),
        setup({
          services: []
        }),
        setup({
          services: []
        })
      )
    )
  )
  .subscribe(ctx => {
    console.log(ctx.get('pesho'));
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment