From d60ae8c3f8167af492dad96991ae5cb42b7342e8 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 11 Apr 2024 01:56:14 -0700 Subject: [PATCH] Replace `Switch.profiles` with `Switch.Profile` iterable --- .changeset/three-tools-rhyme.md | 5 ++++ packages/runtime/src/switch/profile.ts | 40 ++++++++++++-------------- 2 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 .changeset/three-tools-rhyme.md diff --git a/.changeset/three-tools-rhyme.md b/.changeset/three-tools-rhyme.md new file mode 100644 index 0000000..75aec52 --- /dev/null +++ b/.changeset/three-tools-rhyme.md @@ -0,0 +1,5 @@ +--- +"nxjs-runtime": patch +--- + +Replace `Switch.profiles` with `Switch.Profile` iterable diff --git a/packages/runtime/src/switch/profile.ts b/packages/runtime/src/switch/profile.ts index 5ef0149..5b74357 100644 --- a/packages/runtime/src/switch/profile.ts +++ b/packages/runtime/src/switch/profile.ts @@ -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); @@ -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); - } - }, -};