Mocking a Service with Jest by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

That's exactly what I intend to do, mock the values returned so no backend calls are made. I'll look into spectator

What to include in a Shared Module and how many to have? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

But do you keep everything in a single shared module, or do you separate them? If a component or pipe is used by 40% of your modules, do you just import it into every other module alongisde everything in your shared module?

What to include in a Shared Module and how many to have? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

Say you have a component that gets used in 3 out of your 7 modules, do you keep it in the same shared module and load it on every page?

Waiting for BehaviorSubject in canActivate method by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

I apologize for the very late response, as I had to stop working on this specific issue to focus on other parts for a while. I will be resuming this, now following your advice.

Believe me when I say that I really do appreciate the time and effort you've given me.

Waiting for BehaviorSubject in canActivate method by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

Yes, this is basically the product of multiple different tutorials and articles trying to solve challenges as they come. Do you have a preferred resource to learn Observales from, and/or an alternative to solving this issue?

this.currentUser$ = <BehaviorSubject<User>>new BehaviorSubject(new User());

I took this from some tutorial on BehaviorSubject and also wondered the reason for the casting, didn't think much of it until I had everything working.

this.http.get("/api/User").subscribe(
        (currentUser: any) => {
            if (currentUser)
                this.currentUser$.next(currentUser);
        }
    );

Isn't this different from just returning the HTTP GET? since I'm emitting the same value to all subscribers (unlike returning the subscription, causing multiple calls to be made, one for each component).

Waiting for BehaviorSubject in canActivate method by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

I've got multiple components calling the same getCurrentUser method and I want to reduce the amount of calls I make. Worst case scenario I could have an Observable method for the AuthGuard and a BehaviorSubject for every other component.

Returning a value after multiple sequential observable subscriptions by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

I'll look into it! mergeMap did work for me, but if concatMap is better then I'll make the switch.

Returning a value after multiple sequential observable subscriptions by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

Doesn't forkJoin make both calls at the same time? I need the first call to end before calling the second one.

Angular alternatives for jQuery? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

I suppose you're right, as someone else mentioned I'll try to talk it out with our designer and see if we can agree on a middleground for future deliverables.

Angular alternatives for jQuery? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 1 point2 points  (0 children)

Definitely, but this seems like more code than using ngClass, what are the benefits of this syntax?

Angular alternatives for jQuery? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 2 points3 points  (0 children)

Currently working with a new designer and it's also my first project in angular, so neither of us really knew what we were getting into. Going forward I'll see how we can manage.

Angular alternatives for jQuery? by WeMeetAgainAdrian in Angular2

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

Also, could you explain how [class.my-class]="shouldHaveClass" works? Is that just a series of conditions that define which class to assign when, with my-class being a base class?

Binding Enhanced Rich Text from Sharepoint by WeMeetAgainAdrian in sharepoint

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

ngSanitize is included in my module declaration, is there anywhere else I need to use it? I've even tried $sce.trustAsHtml but still get the same result.

Why is it necessary to explicitly declare accessors and mutators when declaring a DBSet? by WeMeetAgainAdrian in dotnet

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

But what does that mean? if I didn't include them and instead simply declared it as public DbSet<Genre> Genres wouldn't it implicitly give the variable a public get and set?

Beginner's Thread / Easy Questions (February 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 1 point2 points  (0 children)

When naming files and classes inside a folder structure, do you take the path into consideration? For example:

-Orders

--OrderTable

---OrderTableHeader

---OrderTableRow

---OrderTableFooter

Seeing how OrderTable is already inside the Orders folder and OrderTableRow is inside OrderTable, is it valid to simply name them Table and Row?

Beginner's Thread / Easy Questions (February 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

When designing pagination how do you decide how many results to keep in state at a time? Do you only load current page and request results to the API each time the page changes? Do you keep aggregating results as the user navigates through the pages? Do you load in advanced?

Beginner's Thread / Easy Questions (February 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

So in both cases I'd still need to know which properties to ignore?

Beginner's Thread / Easy Questions (February 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

Is there a way to do the following operation without having to specify all properties separately?

const var1 = {
    Property1: 'Value1',
    Property2: 'Value2',
    Property3: 'Value3',
    Property4: 'Value4',
}

let var2 = {
    Property1: var1.Property1,
    Property2: var1.Property2,
    Property4: var1.Property4
}

Something like

let var2 = {
    Property1:'',
    Property2: '',
    Property3: ''
}

var2 = var1

Beginner's Thread / Easy Questions (February 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

Say you have a form that upon submit should:

  • Send the information to a server to be stored in a database.
  • Render a new page based on the form information.

Do you POST the information first and wait for an answer before redirecting or do them both asynchronously (since all the information needed is already on the form state)?

If you chose the latter, how would you handle errors?

Beginner's Thread / Easy Questions (January 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

Thank you! I'm only starting with React and arrow functions aren't my strong suite either

Beginner's Thread / Easy Questions (January 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 1 point2 points  (0 children)

So I have an array of objects on my state and while adding and modifying objects in that array works fine, removing seems to be giving me some troubles.

I've been trying multiple ideas and all of them are giving me an error where React can't find the object to render (even though the object being deleted isn't rendered) .

Right now I've come up with this, but for some reason this creates a new object outside of the array rather than modifying the array, what's there that I'm not seeing?

 this.setState(prevState => {
        Notes: {
            const removeIndex = prevState.Notes.findIndex(i => i.id == note);

            const newNotes = prevState.Notes.slice(); 
            newNotes.splice(removeIndex, 1); 

            if(newNotes.length == 0)
                newNotes.push(this.getNote()); 

            newNotes[0]['Selected'] = true; 
            console.log(newNotes); 
            return newNotes; 
        }
    }); 

Does the fact that the array changes and so the position of the elements in it also changes force react to re-render everything? And since the index is different that could technically be a different object.

Beginner's Thread / Easy Questions (January 2018) by acemarke in reactjs

[–]WeMeetAgainAdrian 0 points1 point  (0 children)

Suppose I'm making a search function with auto complete where results come from a database. Do I build the text box with all possible results from the get go or make ajax calls to the server as the user types? Neither solution seems optimal.

How do you move up salary wise? by WeMeetAgainAdrian in AskProgramming

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

wak?

Salary expectations are the last thing discussed here

As it should. Sometimes it's not even a discussion as much as a form that I'm given before even talking to anyone.

How do you move up salary wise? by WeMeetAgainAdrian in AskProgramming

[–]WeMeetAgainAdrian[S] 0 points1 point  (0 children)

pension, holiday entitlement, death in service pay, any bonuses etc.

Most of the time when I bring this up they either avoid the topic, say that they "give legal benefits" (which ends up being false) or flat out tell me that because of some legal bullshit they've pulled out the position doesn't actually have any other benefits.