소스 정보
- 저장소
- marcglasberg/bloc_superpowers
- 최근 소스 활동
- 2026년 1월 29일 03:53
- 감지된 SKILL.md 언어
- 영어
- 스타
- 7
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/marcglasberg/bloc_superpowers --skill add-fresh명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | add-fresh |
| description | Add freshness caching to prevent redundant method executions within a time period |
This skill adds freshness caching to prevent redundant method executions within a time period.
Adds the fresh parameter to a mix() call so that:
Ask the user which Cubit method needs freshness caching, or identify methods that:
Add fresh: fresh to the mix() call:
import 'package:bloc_superpowers/bloc_superpowers.dart';
class UserCubit extends Cubit<User> {
UserCubit() : super(User());
void loadData() => mix(
key: this,
fresh: fresh, // Add this line (default: 1 second)
() async {
final user = await api.loadUser();
if (user == null) throw UserException('Failed to load user');
emit(user);
},
);
}
The default freshness period is 1 second. Customize based on how often data changes:
void loadData() => mix(
key: this,
fresh: fresh(freshFor: 5.sec), // Data valid for 5 seconds
() async {
final user = await api.loadUser();
emit(user);
},
);
fresh // 1 second (default)
fresh(freshFor: 5.sec) // 5 seconds
fresh(freshFor: 30.sec) // 30 seconds
fresh(freshFor: 5.minutes) // 5 minutes
fresh(freshFor: 1.hours) // 1 hour
Allow bypassing freshness with a parameter:
void loadData({bool force = false}) => mix(
key: this,
fresh: fresh(
freshFor: 5.sec,
ignoreFresh: force, // When true, ignores freshness
),
() async {
final data = await api.getData();
emit(data);
},
);
// Normal call - respects freshness
cubit.loadData();
// Force refresh - ignores freshness
cubit.loadData(force: true);
Track freshness separately for different parameters:
void loadUser(String userId) => mix(
key: this, // State tracking uses UserCubit
fresh: fresh(
key: (UserCubit, userId), // Freshness tracked per userId
freshFor: 5.sec,
),
() async {
final user = await api.loadUser(userId);
emit(state.copyWith(users: {...state.users, userId: user}));
},
);
With this setup:
context.isWaiting(UserCubit) shows loading for any usercubit.loadData(); // ✓ Executes, data loaded, marked fresh
// ... 2 seconds later (within 5 sec freshness) ...
cubit.loadData(); // ✗ Skipped, data still fresh
// ... 4 more seconds later (total 6 sec, past freshness) ...
cubit.loadData(); // ✓ Executes, data reloaded
If the method fails, freshness is not set. This allows immediate retry:
cubit.loadData(); // ✗ Fails with error
cubit.loadData(); // ✓ Executes immediately (not marked fresh due to error)
Prevent reloading when navigating back to a screen:
void loadScreenData() => mix(
key: this,
fresh: fresh(freshFor: 30.sec),
() async {
final data = await api.getScreenData();
emit(data);
},
);
void loadProducts({bool force = false}) => mix(
key: this,
fresh: fresh(freshFor: 1.minutes, ignoreFresh: force),
() async {
final products = await api.getProducts();
emit(state.copyWith(products: products));
},
);
// In widget
RefreshIndicator(
onRefresh: () => cubit.loadProducts(force: true),
child: ProductList(),
)
void loadData() => mix(
key: this,
fresh: fresh(freshFor: 10.sec),
retry: retry,
() async {
final data = await api.getData();
emit(data);
},
);
void loadData() => mix(
key: this,
fresh: fresh(freshFor: 5.sec),
nonReentrant: nonReentrant,
retry: retry,
() async {
final data = await api.getData();
emit(data);
},
);
Clear freshness manually when needed:
// Clear freshness for a specific key
Superpowers.removeFreshKey(UserCubit);
Superpowers.removeFreshKey((UserCubit, userId));
// Clear all freshness keys
Superpowers.removeAllFreshKeys();
Use cases for manual clearing:
Good candidates:
Consider freshness duration:
Not recommended:
class ProductCubit extends Cubit<ProductState> {
ProductCubit() : super(const ProductState());
// Products stay fresh for 1 minute
void loadProducts({bool force = false}) => mix(
key: this,
fresh: fresh(freshFor: 1.minutes, ignoreFresh: force),
retry: retry,
() async {
final products = await api.getProducts();
emit(state.copyWith(products: products));
},
);
// Product details fresh per product ID
void loadProductDetails(String productId) => mix(
key: (ProductDetails, productId),
fresh: fresh(freshFor: 30.sec),
() async {
final details = await api.getProductDetails(productId);
emit(state.copyWith(
productDetails: {...state.productDetails, productId: details},
));
},
);
}
Ask the user: