by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 15 2019 16:45
    johannesjo commented #20
  • Sep 21 2019 04:04
    JimTheMan closed #16
  • May 04 2019 00:15
    felixunivers edited #17
  • Apr 29 2019 21:30
    felixunivers opened #17
  • Apr 10 2019 21:15
    rezord opened #16
  • Jan 31 2019 20:44
    alex-okrushko commented #1511
  • Jan 31 2019 20:21
    brandonroberts edited #1538
  • Jan 31 2019 20:20
    brandonroberts edited #1538
  • Jan 31 2019 20:18
    brandonroberts labeled #1538
  • Jan 31 2019 20:18
    brandonroberts labeled #1538
  • Jan 31 2019 20:18
    brandonroberts opened #1538
  • Jan 31 2019 12:11
    timdeschryver closed #1536
  • Jan 31 2019 12:11
    timdeschryver commented #1536
  • Jan 31 2019 12:08
    timdeschryver closed #1537
  • Jan 31 2019 12:08
    timdeschryver commented #1537
  • Jan 31 2019 11:59
    olefrank commented #1036
  • Jan 31 2019 11:59
    olefrank commented #1036
  • Jan 31 2019 11:39
    jonrimmer commented #103
  • Jan 31 2019 09:42
    j00y opened #1537
  • Jan 31 2019 09:33
    omarperezm edited #1536
Mike Herbert
@mherbert71_twitter
so I have an interesting ‘leak’, where after resetting a property (this property is a complex object) in the state, the state is correctly represented (property and it’s sub-properties), however there is an Object in memory (found using Chrome DevTools -> Memory Heap Snapshot) that still seems to be referenced. thoughts anyone? using @ngrx/store 8.6.0
Derek
@derekkite
@mherbert71_twitter if you have a reference to the object somewhere it won't get rid of it. let p = myobject means p has a reference to myobject.
dev-ster
@dev-ster
Can we combine the selectors to tidy that up?
export const selectAll = createSelectorFactory<{}, Dictionary<OrderView>>(arrayMemoizer)(
        selectEntities,
        UserSelectors.selectEntities,
        DentistSelectors.selectEntities,
        PatientSelectors.selectEntities,
        MaterialSelectors.selectEntities,
        WorkTypeSelectors.selectEntities,
        ToothColorSelectors.selectEntities,
        (
            entities: Dictionary<Order>,
            users,
            dentists,
            patients,
            materials,
            workTypes,
            toothColors
        ) => Object.values(entities).reduce((acc, entity) => {
            if ( entity.completeness === 2 ) acc.push(createOrderView(
                entity,
                users,
                dentists,
                patients,
                materials,
                workTypes,
                toothColors
            ));

            return acc;
        }, [])
    );


    export const selectById = (id: number) => createSelectorFactory<{}, OrderView>(objectMemoizer)(
        selectEntities,
        UserSelectors.selectEntities,
        DentistSelectors.selectEntities,
        PatientSelectors.selectEntities,
        MaterialSelectors.selectEntities,
        WorkTypeSelectors.selectEntities,
        ToothColorSelectors.selectEntities,
        (
            entities: Dictionary<Order>,
            users,
            dentists,
            patients,
            materials,
            workTypes,
            toothColors
        ) => createOrderView(
            entities[id],
            users,
            dentists,
            patients,
            materials,
            workTypes,
            toothColors
        )
    );
It’s redundant
Ohm0n
@thecyberd3m0n_gitlab
Hi people
I have some problems regarding writing tests to ngrx/store based chat library
  fit('should be able to create and join session', async (done) => {
    // let's create session
    dispatchers.init();

    const mainSub = selectors.mode$.subscribe((mode) => {
      if (mode === SecureChatMode.EMPTY) {
        dispatchers.setupProfile({
          name: 'test'
        });
      } else if (mode === SecureChatMode.READY) {
        dispatchers.startSession();
        const pendingSessionsSub1 = selectors.pendingSessions$.subscribe((pendingSessions: PendingSession[]) => {
          if (pendingSessions.length > 0) {
            expect(pendingSessions[0].id).toBeTruthy();
            const id = pendingSessions[0].id;
            mainSub.unsubscribe();
            pendingSessionsSub1.unsubscribe();
            TestBed.resetTestEnvironment();
            dispatchers.init();
            const secondSub = selectors.mode$.subscribe((mode) => {
              debugger;
              if (mode === SecureChatMode.EMPTY) {
                dispatchers.joinSession({ sessionId: id });
                done();
              }
            });
          }
        });
      }
    });
  });

});
That's how test looks like now. The problem is I need 2 instances of store to test creating session and joining to that session
the client who joins the session should be a new client, that has no same identity as user who creates the session
whould anybody has any idea how to test ngrx/store based chat library?
one guy on angular forum suggested that I shouldn't have global singletons and store ;)
RoboZoom
@RoboZoom
I don't have much experience in testing ngrx, still learning myself - but are you mocking the store?
Ohm0n
@thecyberd3m0n_gitlab
ok I managed to write it
no, I don't want to
it's not a atomic unit test, I want to test behaviour of whole library
my mistake was I treat it('should do something', () => {...}) as single test
so now test looks like this:

import { MasterSessionService } from './../lib/services/masterSession.service';
import { TestBed, async } from '@angular/core/testing';
import 'firebase/database';
import { SecureChatDispatchers } from '../lib/services/secure-chat.dispatchers';
import { SecureChatSelectors } from '../lib/services/secure-chat.selectors';
import { SecureChatMode } from '../lib/store/reducers/secure-chat.reducer';
import { activeSessionsAdapter } from './../lib/adapters/activeSessions.adapter';
import { messagesStateAdapter } from './../lib/adapters/decryptedMessages.adapter';
import { secureChatSessionsAdapter } from './../lib/adapters/secureChatSession.adapter';
import { configureTestingModule } from './configureTestBed';
import { PendingSession } from '../lib/models/pendingSession.model';
import { ActiveSession } from '../lib/models/activeSession.model';

fdescribe('Test secure-chat', () => {
  let dispatchers: SecureChatDispatchers;
  let selectors: SecureChatSelectors;
  let masterSessionService: MasterSessionService;
  let sessionId: string;
  beforeEach(
    configureTestingModule
  );
  beforeEach(() => {
    dispatchers = TestBed.inject<SecureChatDispatchers>(SecureChatDispatchers);
    selectors = TestBed.inject<SecureChatSelectors>(SecureChatSelectors);
    masterSessionService = TestBed.inject<MasterSessionService>(MasterSessionService);
  });

  it('should be able to create session', async (done) => {
    // let's create session
    dispatchers.init();

    const mainSub = selectors.mode$.subscribe((mode) => {
      if (mode === SecureChatMode.EMPTY) {
        dispatchers.setupProfile({
          name: 'test'
        });
      } else if (mode === SecureChatMode.READY) {
        dispatchers.startSession();
        const pendingSessionsSub1 = selectors.pendingSessions$.subscribe((pendingSessions: PendingSession[]) => {
          if (pendingSessions.length > 0) {
            expect(pendingSessions[0].id).toBeTruthy();
            sessionId = pendingSessions[0].id;
            mainSub.unsubscribe();
            pendingSessionsSub1.unsubscribe();
            done();
          }
        });
      }
    });
  });

  it('should be able to join to remembered session', async (done) => {
    dispatchers.init();
    selectors.mode$.subscribe((mode) => {
      if (mode === SecureChatMode.EMPTY) {
        selectors.activeSessions$.subscribe((activeSessions: ActiveSession[]) => {
          if (activeSessions.length > 0) {
            expect(activeSessions[0].id).toBeTruthy();
            done();
          }
        });
        dispatchers.joinSession({
          sessionId
        });
      }
    });
  });

});
first 'it' creates the session and stores id by first client. Second 'it' joins that session. beforeEach has callback 'configureTestingModule' - it means Angular will restart itself between 'it's'. So that's kind of whole workflow test (now it passes)
RoboZoom
@RoboZoom
Aren't the 'it' statements run in parallel? Are you counting on the first 'it' to be run before the second 'it'?
@thecyberd3m0n_gitlab
Ohm0n
@thecyberd3m0n_gitlab
if yes, I should disable this behaviour
but I see test are passed now
Ohm0n
@thecyberd3m0n_gitlab
no it doesn't run by parallel by default, you need to add 'parallel' into config (https://stackoverflow.com/questions/42965037/is-it-possible-to-run-parallel-tests-using-karma) but it is not desired behaviour in this case. My CI has some time and it doesn't need to be ultra fast.
RoboZoom
@RoboZoom
ah, cool
RoboZoom
@RoboZoom
I'm trying to write my first effect, but the compiler is telling me that my object exiting the ofType function is of type never
addPerson$ = createEffect(() =>
      this.actions$.pipe(
          ofType(AdminActions.AdminAction.addPerson),
          tap((x) => "Add Person Effect Called!"),
Here, x in final line is typed as (parameter) x: never
Am I doing something wrong?
RoboZoom
@RoboZoom
The follow on is that in later code, I want to access a prop

Which I'm doing like this:

 concatMap((action) =>
          this.dataService
            .addNewPerson(action.myPerson)

But the compiler is providing an error when I try to access the prop

I can cast the action as a type, but I don't think I'm creating a type - I'm just defining the action via the NgRx createAction factory function
RoboZoom
@RoboZoom
ok - to answer my own question, if I pass the action itself, and not the string, then the type inference works to understand properties
RoboZoom
@RoboZoom
If I have a member property of an NgRx entity that is an array of literals (either string literals, or numbers), will that cause reference issues?
I want to have a way to list Id's for other objects I'm storing, like addresses
dev-ster
@dev-ster
How do you manage updates of many to many relations in ngrx?
HMAIDI Thamer
@hmaidithamer
Hello All,
Can lazy loaded features communicate state between features with ngrx in Angular 9?
dev-ster
@dev-ster
@hmaidithamer Sure, you can do that
HMAIDI Thamer
@hmaidithamer
@dev-ster i have two module person and card and i use lazy loading when i try to access to the card state i have an error that card state undefined because still not loaded
i need to access to the card state from person module
dev-ster
@dev-ster
@hmaidithamer If you need the state of the lazy loaded module that isn’t loaded yet you have to restructure your imports
You need to import the store you need before you can access it
HMAIDI Thamer
@hmaidithamer
image.png
@dev-ster
yes that's what i do exactly
@dev-ster
i import the needed feature inside my module
dev-ster
@dev-ster
Try to use combinereducers
You shouldn’t invoke the store module multiple times inside on module
dev-ster
@dev-ster
screenshot 2020-06-28 um 14.40.21.png
I’m trying to find out why the bundle size is too big
Do you spot anything suspicious?
I’m at an early stage with a few routes. Lazy loading won’t be an issue
I’m using Angular Material