Skip to content

Instantly share code, notes, and snippets.

export const customStorage: Storage = {
length: 0,
clear: function(): void {
if (window && window.localStorage) {
window.localStorage.clear();
this.length = window.localStorage.length;
}
},
getItem: function(key: string): string | null {
try {
import { Injectable } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { selectAllProjects, selectCurrentProject } from '..';
import { Project } from '../../projects/project.model';
import { ProjectsState } from './projects.reducer';
import { LoadProjects, AddProject, UpdateProject, DeleteProject, SelectProject } from './projects.actions';
@Injectable({
const entities = posts.reduce(
(entities: { [id: string]: Post }, post: Post) => {
return {
...entities,
[post._id]: post,
};
},
{
...state.entities,
}
import {
Directive,
Renderer2,
TemplateRef,
ViewContainerRef,
Input
} from '@angular/core';
@Directive({
selector: '[appMy]'
providers: [
{
provide: LOCALE_ID,
useFactory: (translate: I18nService) => {
return translate.language;
},
deps: [I18nService]
}
]
Service
import { Injectable } from '@angular/core';
import {TranslateService, LangChangeEvent} from '@ngx-translate/core';
export function extract(s: string) {
return s;
}
@Injectable({
providedIn: 'root'
const autoprefixer = require("autoprefixer");
const eslintFormatter = require("react-dev-utils/eslintFormatter");
const flexbugsFixes = require("postcss-flexbugs-fixes");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
// Utils
const envs = require("./env");
const paths = require("./paths");
// App
import { AuthLayoutMain } from "./features/auth/layout";
const BlogLayoutMain = lazy(() => import('./features/blog/layout'));
//import { BlogLayoutMain } from "./features/blog/layout";
import { AdminLayoutMain } from "./features/admin/layout";
const App = () => {
return (
<MuiThemeProvider theme={theme}>
<Suspense fallback={<div>Loading...</div>}>
import axios from "./axios";
import { Storage } from "./utils/storage";
const setupAxiosInterceptors = onUnauthenticated => {
const onRequestSuccess = config => {
console.log("request success", config);
const token = Storage.local.get("auth");
if (token) {
config.headers.Authorization = `${token.token}`;
}
const autoprefixer = require("autoprefixer");
const eslintFormatter = require("react-dev-utils/eslintFormatter");
const flexbugsFixes = require("postcss-flexbugs-fixes");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require("webpack");
// Utils
const envs = require("./env");
const paths = require("./paths");