Skip to content

Commit

Permalink
Replace Switch.profiles with Switch.Profile iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Apr 11, 2024
1 parent cba5ff3 commit d60ae8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-tools-rhyme.md
@@ -0,0 +1,5 @@
---
"nxjs-runtime": patch
---

Replace `Switch.profiles` with `Switch.Profile` iterable
40 changes: 19 additions & 21 deletions packages/runtime/src/switch/profile.ts
Expand Up @@ -48,6 +48,25 @@ export class Profile {
_init();
return proto($.accountProfileNew(uid), Profile);
}

/**
* Can be used as an iterator to retrieve the list of user profiles.
*
* @example
*
* ```typescript
* for (const profile of Switch.Profile) {
* console.log(profile.nickname);
* }
* ```
*/
*[Symbol.iterator]() {
_init();
const pr = $.accountProfiles();
for (const p of pr) {
yield proto(p, Profile);
}
}
}
$.accountProfileInit(Profile);

Expand Down Expand Up @@ -96,24 +115,3 @@ export function selectProfile() {
if (p) proto(p, Profile);
return p;
}

/**
* Can be used as an iterator to retrieve the list of user profiles.
*
* @example
*
* ```typescript
* for (const profile of Switch.profiles) {
* console.log(profile.nickname);
* }
* ```
*/
export const profiles = {
*[Symbol.iterator]() {
_init();
const pr = $.accountProfiles();
for (const p of pr) {
yield proto(p, Profile);
}
},
};

0 comments on commit d60ae8c

Please sign in to comment.