Skip to content

Commit

Permalink
Merge pull request aws-amplify#6417 from erinleigh90/fix-migration-utils
Browse files Browse the repository at this point in the history
fix: fix utils examples in upgrade guide
  • Loading branch information
renebrandel authored Nov 15, 2023
2 parents 660737f + 7ee98ca commit 719d47c
Showing 1 changed file with 51 additions and 21 deletions.
72 changes: 51 additions & 21 deletions src/fragments/lib/troubleshooting/common/upgrading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -855,24 +855,37 @@ As of v6 of Amplify, you will now import the functional API’s directly from th
```
import { ServiceWorker, Cache, Hub, I18n, Logger } from 'aws-amplify';
// Service Worker const serviceWorker = new ServiceWorker();
// Cache Cache.setItem(key, value, [options]);
// Hub (Listening for messages) class MyClass { constructor() { Hub.listen('auth', (data) => { const { payload } = data; this.onAuthEvent(payload);
console.log('A new auth event has happened: ', data.payload.data.username + ' has ' + data.payload.event); }) }
onAuthEvent(payload) {
// ... your implementation
}
// Service Worker
const serviceWorker = new ServiceWorker();
// Cache
Cache.setItem(key, value, [options]);
// Hub (Listening for messages)
class MyClass {
constructor() {
Hub.listen('auth', (data) => {
const { payload } = data;
this.onAuthEvent(payload);
console.log('A new auth event has happened: ', data.payload.data.username + ' has ' + data.payload.event);
})
}
onAuthEvent(payload) {
// ... your implementation
}
}
// Internationalization I18n.setLanguage('fr');
// Internationalization
I18n.setLanguage('fr');
// Logger const logger = new Logger('foo');
// Logger
const logger = new Logger('foo');
logger.info('info bar'); logger.debug('debug bar'); logger.warn('warn bar'); logger.error('error bar');
logger.info('info bar');
logger.debug('debug bar');
logger.warn('warn bar');
logger.error('error bar');
```
</Block>
Expand All @@ -888,20 +901,37 @@ import {
ConsoleLogger
} from 'aws-amplify/utils';
// Service Worker const serviceWorker = new ServiceWorker();
// Service Worker
const serviceWorker = new ServiceWorker();
// Cache Cache.setItem(key, value, [options]);
// Cache
Cache.setItem(key, value, [options]);
// Hub (Listening for messages) class MyClass { constructor() { Hub.listen('auth', (data) => { const { payload } = data; this.onAuthEvent(payload);
console.log('A new auth event has happened: ', data.payload.data.username + ' has ' + data.payload.event); }) }
// Hub (Listening for messages)
class MyClass {
constructor() {
Hub.listen('auth', (data) => {
const { payload } = data;
this.onAuthEvent(payload);
console.log('A new auth event has happened: ', data.payload.data.username + ' has ' + data.payload.event);
})
}
onAuthEvent(payload) { // ... your implementation } }
onAuthEvent(payload) {
// ... your implementation
}
}
// Internationalization I18n.setLanguage('fr');
// Internationalization
I18n.setLanguage('fr');
// Console Logger const logger = new ConsoleLogger('foo');
// Console Logger
const logger = new ConsoleLogger('foo');
logger.info('info bar'); logger.debug('debug bar'); logger.warn('warn bar'); logger.error('error bar');
logger.info('info bar');
logger.debug('debug bar');
logger.warn('warn bar');
logger.error('error bar');
````
</Block>
Expand Down

0 comments on commit 719d47c

Please sign in to comment.