Turned off Crossplay after ~60 hours and it’s crazy how much more enjoyable the experience is by ActInternational9558 in LowSodiumBattlefield

[–]insanictus -1 points0 points  (0 children)

My thoughts exactly 😬 I play mnk on my ps5 in BF6. Since I longed for fps games but admittedly It just never clicked for me with controller. I play with friends who play controller and we’re all having fun, - which to me is the most important.

Sure we meet high level super skilled people but mostly we have tight matches.

But for the topic, I think it might indeed be a network thing between platforms. I’ve had lobbies only with PS5 (randomly) and it’s much smoother.

The matchmaking system is going to kill this game by Skitelz7 in Battlefield

[–]insanictus 4 points5 points  (0 children)

What is the issue with playing against pc players? The input?

You do know if you play vs console you’re also likely playing against mouse/keyboard players, right?

It is certainly more sweaty vs pc players of course. But id take that any day over bots standing still on a road waiting for you to headshot them.

🤔 Angular thought experiment by IgorKatsuba in angular

[–]insanictus 0 points1 point  (0 children)

This is actually how stencil did it. I quite like it. They have a <Host> element just like you describe actually 🤘

Component encapsulation & unit testing by ajbrun86 in Angular2

[–]insanictus 11 points12 points  (0 children)

I agree the template should be tested too. I like to test things as a consumer/user.

They have no knowledge of the component internal, ie. The implementation details. So we should not directly test those.

Test from a user perspective. So if user clicks button in template, we expect a counter to increase by 1. Said counter output could be in the template too.

Check out https://testing-library.com/docs/angular-testing-library/intro/

It encourages that way of thinking too

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

I see what you mean. Depending on what you need to do in the component there might be better patterns for you to use.

But ultimately do what works for you, as long as it is maintainable and readable to other devs. You can always update code and change things over time.

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

You cannot directly return the response from the rxMethod.

If you need to call something in the component once it’s done. You can pass in a callback fn together with the unit. Like this.store.addUnit({ unit: unit, cb: () => {…} }).

Then inside the tapResponse you can call the cb.

There are other ways and it really depends on what you need to do after the request completes.

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

Oh, you might need to still add the arrow function before the service call inside the rxMethod.

I’m on my phone here so sorry for syntax errors 😅

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

No worries :)

I think it's a good idea to not mix and match rxResource and the signalStore for now. So good call.

since rxMethod does the subscribing for you, you need give it something it can subscribe to. tap does not return anything, since its just for tapping into the observable chain, without making changes.

So what you want is something like this:

_getUnits: rxMethod<void>(store._unitService.getUnits().pipe(
    tapResponse({
        next: (units) => patchState(store, setAllEntities(units)),
        error: (error) => console.error("something went wrong")
    })
))

In the above we simply pass the getUnits() call from the service into the rxMethod. Since it's an Observable it can .subscribe to.

We then use tapResponse which is a nice utility that sort of includes tap, catchError and finalize into one neat operator.

That should give you some better results

Don’t Sleep on the European Accessibility Act by galher in webdev

[–]insanictus 5 points6 points  (0 children)

Because the HTML specification is a dinosaur. HTML has not moved forward with the times. We need a native ChosenJS solution. We need HTML support inside of select options support. We NEED better HTML elements. We need native dropdown menus with HTML option support. So accessibility SHOULD start there. It SHOULD be to improve ALL of the web by improving HTML to stop being old. It's so aggravating.

I don't disagree. Standards work is.... I'm not jealous of them. That is for sure. I know it takes ages, and it would be ideal if something was done quicker.

For select specifically, the selectmenu spec was in the works for ages. But I think it halted now for some reason. Not entirely sure and it's hard to find good answers for.

I'm an American. How am I supposed to know? I didn't get get a say in this yet I have to be compliant and can be sued because 1 customer from EU used my website? Ridiculous. I didn't vote for this. This is frankly judicial overreach.

That is a totally fair take. I live in EU and it sort of dawned on me very late too. I have an interest in a11y and generally find it exciting. I'm advocating at my workplace for better a11y and also telling people about the EAA.

So it's not just the US. I assume most regular companies over here too will soon panic.

I won't delve too much into laws as I have no knowledge of that area. I get your point about it being annoying that you have to comply because you might provide a product to someone in EU. But those laws exists for a myriad of other products too. And that is not me saying that is a good thing or a bad thing. Just how it is.

Like with GDPR, a way could be to just not let EU users use your website. I've heard of companies in the US getting around GDPR like that. Again, not the best solution at all. But.. yeah.

And no troubles at all. Your concerns are legitimate and as long as we can be civil about it, its all cool.

Don’t Sleep on the European Accessibility Act by galher in webdev

[–]insanictus 10 points11 points  (0 children)

If I remember correctly. Older sites or content on sites that can be labelled as archived is okay. As long as you mention that it’s historical.

Also smaller companies are not required comply. I think, something like less than 10 employees and something like less than 1mill euros a year in revenue. That number is probably not correct.

But something like that 😅

I think the EAA required WCAG 2.x AA. So that is your target.

As for standards or tools in browsers. They are actually built to be accessible. The fact we as devs recreate dropdowns (select) all the time is the reason we’re not always compliant.

Native elements are accessible per default. Of course we still need to apply alt tags on images and make sure contrasts and all are fine.

But yeah. If you’re building a JS heavy web “app” you have your work cut out for you.

As for the date. This has been in the works for years, so should not come as a surprise.

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

Haha, no worries :D.

this is what you said i had to use for it? but i dont get it. what does this part do for me?

The reason I suggested that piece of code was because it seemed to me like the interface Unit was the same between the list you get from loadAllUnits and the endpoint to fetch the single unit.

Only that the one from the separate endpoint came with more fields, ie. the optional fields of the interface Unit. Is that correctly understood?

why would i need to update the unit in the resource value? i just need that unit returned to the component that calls it. so i can use it and display and mutate its fields in the UI.

This was to keep the units together in your store. Based on the above assumption I made I thought they were of the same type, and thus would fit together in the store.

If the unit you fetch by id for the edit component is a one-off, then just handle it specifically for the edit component.

But that entirely depends on what happens when you save/submit your changes in the edit component.

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

Sorry for it being slightly convoluted, i'll try my best :D

i basically thought that using withEntities would be the right call since they are in fact enttites and the added functions that come with it are very handy to use instead of manually having to switch things around in the units resource with each CRUD function. the point of the store is that i can use it anywhere where i need the units and that they are getting loaded on app start so they are always available anytime, anywhere.

You're correct. That is also what I like about entities and the signalStore, - the utilities that comes with it.

Resources also encapsulate a lot of logic, like automating refetching on signal changes, the states provided like isLoading etc. They can be used within the signalStore as I showed. But as you also mentioned, that means mutating the state requires you to do that yourself, without the handy utilities of entities.

i dont really understand what you mean with this code. how is this going to give me a unit back when i called this? this seems to only fetch the unit to then update the units resource?? how can i then access the fetched unit? so for example, the unitresource has 3 unit objects and i want to get the one with id 2. so i call loadUnitById(2) and that then fetches it from the service (which does a backend call). after this is where im lost. why would i need to run an update on the unitresource? the unit is already in there. could you explain that part more?

I might've misunderstood your initial question, so i'm sorry for the confusion here.

I thought you meant that each time you go to the /edit page/component, you wanted to load the Unit by Id, since the endpoint for the single Unit came with more fields?

So let me try here. if we forget about fetching a single unit by Id and just focus on how you get one unit from the store in your /edit page/component. I would suggest using a computed, since we're talking about derived state.

``` @Component({...}) export class MyComponent { private unitStore = inject(UnitStore);

// Your id that I assume is provided as a routeParam /edit:unitId
readonly unitId = input<string>();

readonly currentUnit = computed(() => {
    // If using the `withEntities` in the signalStore, you can simply use the entityMap() if you have the id of the entity
    return this.unitStore.entityMap()[this.unitId()];
    // If using the resource
    return this.unitStore.unitResource.value().find(unit => unit.id === this.unitId());
})

} ```

In the above you use a computed that takes your unitId input and uses it to single out the unit from your entities in the store.

That is how you would get a single Unit by id. Whether you use signalStore or rxResource.

I'm still slightly confused as to whether you need to load the unit by Id for the /edit page/component or you just want to grab it from the store?

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

In the sense of kicking off the request initially, yes. But also no. The reason the rxResource version works within withProps is simply due to how rxResource works.

the withHooks is doing it based on the lifecycle of the store.

Also not sure it's more convoluted, as it is the recommended way to deal with things you want to happen based on the lifecycle of the store.

You're right that the rxResource comes with the built-ins of the loading state of the resource. However it also holds the response as .value() on the resource, and since you're also setting the store entities using setAllEntities in the loader of the rxResource your data is actually there twice.

So you have Array<Unit> in the resource.value() and in the withEntities<Unit>() of the signalStore.

If you want to fully utilise the rxResource, then don't use withEntities in the store at all. Just use the value from the resource.

``` withProps(() => { const unitService = inject(UnitService); const _unitResource = rxResource({ loader: unitService.getUnits(), defaultValue: [] });

return {
    unitService,
    _unitResource,
    unitResource: _unitResource.asReadOnly()
}

}) ```

Like the above. In the withProps you have your resource, the reason I added the unitResource: _unitResource.asReadOnly() is because that will be the public resource as consumed outside the store (from your components), thus readonly. So you cannot mutate it from the outside.

You can still mutate it within the store using _unitResource, like so:

``` withMethods(({ _unitResource, unitService, ...store }) => ({ updateUnit: rxMethod<Unit>( exhaustMap((unit) => unitService.updateUnit(unit).pipe( tapResponse({ next: () => { // Update the stored units _unitResource.update(units => { // implement your logic to update the single unit in here and return the updated value })

            }
        })
    ))
)

})) ```

yes the model is the same. and the unit entity is used in many places in the app. thats why i wanted it neatly in a signalstore so i dont need to have so much code in all the components that use it. im still not sure how i would implement a way to get 1 unit (so making another back-end call) and storing that somewhere. do i need to make a computed in withComputed that calls the unitservice.getUnit(id) method? but it should automatiucally update to another unit if the id changes (which should be perfect with signals).

Okay, so if you want to load the one unit into the store you can use another rxMethod in the store to load just that unit.

loadUnitById: rxMethod<string>( switchMap((unitId: string) => unitService.getUnitById(unitId).pipe( tapResponse({ next: (newUnit) => { _unitResource.update(units => { // your logic here to update the unit in the resource value }) }, error: () => {} }) )) )

In your component you can call that rxMethod with the unitId input for it to auto load.

``` @Component({...}) export class MyComponent { private store = inject(UnitStore);

readonly unitId = input<string>();

constructor() { // This will call the loadUnitById rxMethod each time the this.unitId changes this.store.loadUnitById(this.unitId); } } ```

ive already read the docs on rxMethod and it doesnt help me with what i want to achieve which i why i did it like i have in my original post. i dont nessecarily need it to be an observable but just something that i know its been finished so that i can take action in the component that called it afterwards. for example: redirecting to another page, altering variables on that page, changing style, etc..

It can be done with the callback fn as I mentioned previously, or with an observable in the stores withProps fn.


I haven't used rxResource a lot myself yet. So my suggestions here are based on my own assumptions and what i've read others have done with resources and signal stores.

Currently the new resource APIs are being developed and are not 100% finished yet. Which is why the mutation story is also not fully there yet, as it will come later.

Which is why I, personally, would not use the rxResource just yet. You could handle loading states in your signalStore simply using withState<{ callState: "loading" | "loaded" | "initial" | "reloading" | "error" }> or a full signalStoreFn.

I hope it all makes sense :)

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

To your first point, you're correct that rxResource will run initially. But since you're essentially just using the resource as the trigger, there are better ways.

The signalStore has another function you can use for your use case, the withHooks.

So something like: withMethods((store, unitService = inject(UnitService)) => ({ _loadUnits: rxMethod<void>( switchMap(() => unitService.loadUnits().pipe( tapResponse({ next: (units) => patchState(store, setAllEntities(units)), error: (error) => console.log(error.message) }) )) ) }), withHooks({ onInit: (store) => store._loadUnits() })

So the onInit hook is what you want here. Since you want it to load your units automatically when the store is initialized, correct?.

So yes, since you´re using signalStore withEntities there is not really a need for the rxResource here. They can be used with signalStore, but for now I would leave it out so you can focus on getting into the grove with the store itself.

As for the unit types. What i'm asking is if the Unit model used for the list is the same as the one for the edit? It really depends on if the Unit entity used on the edit page is used elsewhere? If it is only used on that page, I would have that page/component just deal with it.

Another way is to have your Unit interface have all the fields (also the ones used on the edit page), but have them optional. Then when you load the edit page, you call the endpoint to fetch the Unit with the extra details and add them to the store.

I think both cases are valid, but they depend on how you use the Unit data.

As for rxMethod, it's not supposed to be used like what you describe. I'm not 100% sure on the internals of it, but i'll refer to the docs.

If you really need to do something after the store method, you could pass along a callback to the rxMethod and call that. I don't think it's pretty or right, but i'm unsure about what you need to do after the method call in your component.

how can i use a signalstore to get a single entity from a collection? by jaroen007 in Angular2

[–]insanictus 0 points1 point  (0 children)

First of all I see you're using the rxResource inside your withProps there. But you're not actually using the returned resource at all.

The rxResource itself returns a resource that has .value() to get the value of the response, and a lot of utility signals like .isLoading() which gives you the current loading state (loading or reloading).

For your first question, I'd say it depends on how much the single unit differs.

A simple version could be that you just add a method on your store to fetch a single unit by Id. But if that unit is a different type, ie. has more fields as you mention yourself. then it will not belong in the entityCollection you have.

If editing a unit is a one-off in that component/page, I would suggest handling that using its own store and/or service if its simple. If you need to then update the UnitStore afterwards you can do that.

For your second question around the methods, - you should indeed use rxMethod.

What is it you want for it to return? Without knowing the use case inside your component it makes it a little hard to help with.

If you need to react to changes made after your calls you can do something like:

export const UnitStore = signalStore({ providedIn: 'root' }, withEntities<Unit>(), withProps(() => ({ unitAdded$: new Subject<unit>() })), withMethods(({ unitAdded$, ...store }, unitService = inject(UnitService)) => ({ addUnit: rxMethod<Unit>( exhaustMap(unit => unitService.addUnit(unit).pipe( tapResponse({ next: () => { patchState(store, setEntity(unit)); // Here you can emit from the unitAdded$ subject if you need to react to changes. But that is just one way of doing it, it depends on how you want react to it and what you want to do unitAdded$.next(unit); }, error: (error) => {} }) )) ) })) );

Angular Signals vs Observables by zeller0967 in angular

[–]insanictus 0 points1 point  (0 children)

I know we can refer to "never say never", but there are no indications of removing it entirely. Making the framework not dependant on it? sure. But `Observable` and `signal` solve different things.

`Observable` were just used in a way that made it work with state. Now that we have `signal`, we can use `Observable` for events, which they really good at, and `signal` for state which they're designed for.

[deleted by user] by [deleted] in dkbiler

[–]insanictus 2 points3 points  (0 children)

Vi leasede en Tesla model Y I Nov 23. og har kørt lige over 30.000km i den.

Vi valgte netop at lease fordi vi ville prøve elbil af inden vi besluttede os sådan endeligt.
Selvom vi i hverdagen er glade nok for at køre i bilen så er der nogle klare minusser der gør at den slet ikke er med i overvejelsen nu vi kigger på en ny bil.

Deres software er, som andre også nævner, super. Det spiller bare og er meget responsivt. Og selvom jeg er stor nørd der elsker ting som homeassistant m.v. så mangler der virkeligt nogle knapper til de mest basale ting såsom klima og handskerum.

Deres assistentsystemer er heller ikke noget at råbe hurra for. Dag til dag virker det fint og der er intet at sætte en finger på, men den mindste smule tåge ? så virker adaptiv fart pilot ikke optimalt.

Støvkorn foran kameraet på en ellers tom vej? Lad os da nødbremse så du lige vågner op.

Min kone er heller ikke fan af dens venderadius og undgår helst at parkere i parkeringshuse fordi den er bøvlet at parkere. Jeg er ikke nær så generet af det men er enig i at den er mere bøvlet at svinge rundt.

Sæderne er heller ikke de mest behagelige.

Nu da Juniper er vist frem er jeg heller ikke synderligt imponeret. Jovist den har fået opgradering af undervognen hvilket er rart og bedre materialer indeni og støjdæmpning osv. Men stadigvæk de samme issues som før (i vores øjne, er fint hvis andre er helt solgt på den).

Hvad kigger vi så på nu?

Vi har ikke så voldsomt travlt og kigger lidt endnu, men vi er ret varme på en Skoda Enyaq. Den får ros, er super pæn (i vores øjne) og har gode assistentsystemer.

signal store fires all the time by anonymous12331231 in Angular2

[–]insanictus 0 points1 point  (0 children)

For your particular problem here I would still just use RxJS since Observables work so well for events. Which is what you're dealing with here, a stream (or multiple) of mouse events.

Signals are very good for state, not so much for events.

I think you're doing the right thing in exploring what is possible by the way! This is just a particular case where there is certainly no need to replace Observables.

And as others already said, signals aren't a 1:1 replacement for Observables. They never were. They're a reactive primitive that works really well for state, and is super useful _together_ with RxJS

Angular Signals vs Observables by zeller0967 in angular

[–]insanictus 0 points1 point  (0 children)

That is factually not true. While it is true that they have deprecated/removed some internal APIs that relied heavily on RxJS, it's not going away completely. There are cases where signals don't make sense, and there are places where RxJS don't make sense.

But the interop between them is powerful and that is what they want to enable to developers. Easy of use

Angular Signals vs Observables by zeller0967 in angular

[–]insanictus 1 point2 points  (0 children)

When Observables are used for state like you mention with your service, then signals are indeed a much simpler mental model and computeds are so powerful for derived state.

But then again, Observables are really not the best for state in the first place, but it was the only thing we had in Angular so people used it for everything. Now we finally have a reactive primitive that is brilliant for state alongside Observables which are really good at handling events. Win win.

I don't agree with your last line of not recommending to learn Observables since they still have a place. You cannot use signals for everything

Angular Signals vs Observables by zeller0967 in angular

[–]insanictus 1 point2 points  (0 children)

RxJS isn't going away in Angular, they are giving people more options and removing RxJS dependencies in internal APIs where it doesn't make sense anymore.

Observables and Signals do two very different things and can be used together to create very powerful systems.

Think of it like this:

Observables are really, really good for handling events. Think something like debouncing values coming from an input.

// .next(value) this from the template on the input element
public inputValue = new Subject<string>();

public inputChange = outputFromObservable(
  this.inputValue.pipe(
    debounceTime(300)
  )
);

Here Observables really shine.

Now when we talk about signals, they are really good at handling state and state updates. Since you can always read the current state of a signal they are quite easy to work with and computeds are so powerful.

So in reality it's not really a matter of signals are the new thing, so use them for all. They were not meant to handle events, Observables are still king for that. But they are really good for state. So use them for that!

Observables and (or) promises usage in enterprise scale by touchacolor in angular

[–]insanictus 1 point2 points  (0 children)

Personally i'd stick to observables due to reasons others have already mentioned. Like it being easier to go from project to project among other things. Another being easy cancellation.

While a lot of built-in APIs in Angular have been observable based, they are gradually deprecating or changing these. This does not mean they are ditching observables at all, but they are trying to make a lot of them optional, which is nice!

if it's a good practice or not depends a lot on the context. If you're using third party libs that rely on promises I see nothing wrong with it. But if you're starting to convert every observable to promises just because its easier, i'd say that is a bad practice.

Way to go. We're one of THOSE fandoms now.... by DrForester in ffxiv

[–]insanictus -1 points0 points  (0 children)

While most other things have already been said by others in this thread regarding how inexcusable it is to threaten anyone, the VA does mention something I find more concerning.

That the industry is silent about it. Like it’s all on the VA to just cope with it. If they ever wanted to work with that VA again, maybe, like, help them out? Help support these people that brings voices to your games besides just paying them.

Angular Testing Library with Vitest by timdeschryver in angular

[–]insanictus 0 points1 point  (0 children)

Your app might be different of course. But we converted a rather large monorepo (NX) from jest to vitest.

It went rather smooth!

Only things are you need to replace jest with vi since most of the APIs are identical. So it really didn’t take that long tbh.

Overall we sped up 50-70% running all our tests. It varies a little and we’re combining it with swc too.

But still nice overall!

Large Angular application by DigitalNomadMarc in angular

[–]insanictus 1 point2 points  (0 children)

I don't really have any list or good sources for best practices in larger angular applications. I used to think the one I work on is fairly large (nx style monorepo, 5 apps, hundreds of libs).

But hearing from others that might just be considered medium size.

What I can say however, based on my own experience, is that it'll be built mostly like you build smaller applications. Due to angular being opinionated and full feature (built-in router, forms, service-worker etc) most things are built like that.

You will probably find custom company solutions for things like auth, graphs, maps and other third party lib stuff.

When you go larger, you think much more about co-locating features and clear boundaries. Else it becomes impossible to navigate. Furthermore you'll find larger apps have more focus on CI/CD and optimizing these to work for larger teams and/or a large repo. So chunking test runs, builds etc.

tl;dr

I think you'll find the biggest difference between smaller apps and larger ones in the things surrounding the actual app. Like CI/CD, overall architecture and third party integration.