投稿時間:2021-05-08 17:25:15 RSSフィード2021-05-08 17:00 分まとめ(28件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia News] 劇場版「機動戦士ガンダム00」、8日からYouTubeで無料配信 ガンダムチャンネル登録105万人突破で https://www.itmedia.co.jp/news/articles/2105/08/news036.html awakeningofthetrailblazer 2021-05-08 16:44:00
IT MOONGIFT dahliaOS - LinuxとFuchsiaを融合させたレスポンシブなOS http://feedproxy.google.com/~r/moongift/~3/4atwxLeOR-k/ dahliaOSLinuxとFuchsiaを融合させたレスポンシブなOSGoogleが開発しているFuchsiaというOSがあります。 2021-05-08 17:00:00
AWS lambdaタグが付けられた新着投稿 - Qiita AWS Lambdaのログのタイムゾーンをいい感じにしたい https://qiita.com/ktoyod/items/571604084f01f000afee Timezoneを変更する方法以下のようにすれば変更できる。 2021-05-08 16:01:58
python Pythonタグが付けられた新着投稿 - Qiita 有向非巡回グラフ(Directed Acyclic Graph) https://qiita.com/maebaru/items/5b6cb981777624ab843c ここでは、受講可能なコースがなくなるか、以前受講したはずのコースが再び現れるサイクルを検出するまで、グラフを段階的に探索していきます。 2021-05-08 16:54:27
python Pythonタグが付けられた新着投稿 - Qiita AWS Lambdaのログのタイムゾーンをいい感じにしたい https://qiita.com/ktoyod/items/571604084f01f000afee Timezoneを変更する方法以下のようにすれば変更できる。 2021-05-08 16:01:58
js JavaScriptタグが付けられた新着投稿 - Qiita OSMを使って現在地の都道府県市町村を取得する https://qiita.com/krohigewagma/items/e7cac8922c4ad058b50e 今回は以下のオプションで利用ています。 2021-05-08 16:43:52
js JavaScriptタグが付けられた新着投稿 - Qiita TypeScriptでよくわかるカリー化 https://qiita.com/riya81/items/78c148f4fa153480ae22 TypeScriptでよくわかるカリー化TypeScriptでよくわかるカリー化カリー化で安全で便利な関数生成環境typescriptNodevカリー化とはカリー化curryingカリー化されたcurriedとは、複数の引数をとる関数を、引数が「もとの関数の最初の引数」で戻り値が「もとの関数の残りの引数を取り結果を返す関数」であるような関数にすることあるいはその関数のことである。 2021-05-08 16:42:30
js JavaScriptタグが付けられた新着投稿 - Qiita LeafletでGPSログ(GPX)地図:標高グラフ追加。 https://qiita.com/ok2nd/items/dba6857b38683e154d4c highcharts 2021-05-08 16:11:14
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Rails form_withでsubmitを行うとルーティングエラー発生。 https://teratail.com/questions/337199?rss=all 記事情報をフォームに入力して、submitを行うとルーティングエラーが発生します。 2021-05-08 16:42:28
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) IntelliJ IDEAの初期起動に失敗する https://teratail.com/questions/337198?rss=all エラーメッセージを見てググってみましたが、解決法が特にでなかったです。 2021-05-08 16:20:21
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) [Swift]APIにより取得したjsonファイルを利用したい https://teratail.com/questions/337197?rss=all 2021-05-08 16:14:42
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) C言語 選択ソートでデータを並び替えたい https://teratail.com/questions/337196?rss=all C言語選択ソートでデータを並び替えたい前提・実現したいことここに質問の内容を詳しく書いてください。 2021-05-08 16:13:38
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) Arduino初心者です。コンパイルできません。 https://teratail.com/questions/337195?rss=all Arduino初心者です。 2021-05-08 16:06:24
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) TypeScriptの配列型の書き方 https://teratail.com/questions/337194?rss=all arraylttgt 2021-05-08 16:00:42
Ruby Rubyタグが付けられた新着投稿 - Qiita メソッドに関する超基礎理解 https://qiita.com/YotaHamasaki/items/5b37a425985076afc661 ex何を、いつ、どんななので先ほどの「勉強するメソッド」内に数学という引数を入れると、def勉強する数学endとなり、「勉強するメソッド」に「何を」という補足情報が入りました。 2021-05-08 16:29:12
AWS AWSタグが付けられた新着投稿 - Qiita Amazon Athena「No output location provided」エラーの対処法 https://qiita.com/blackpeach7/items/22a393f17b805add2574 AmazonAthena「Nooutputlocationprovided」エラーの対処法エラー発生Athenaでパーティション設定時に下記のエラーが発生した。 2021-05-08 16:43:11
AWS AWSタグが付けられた新着投稿 - Qiita AWS Lambdaのログのタイムゾーンをいい感じにしたい https://qiita.com/ktoyod/items/571604084f01f000afee Timezoneを変更する方法以下のようにすれば変更できる。 2021-05-08 16:01:58
Git Gitタグが付けられた新着投稿 - Qiita Gitの本質=commitとはどういうことか https://qiita.com/slmk/items/03bd0b3b3e42ef58a0c1 Gitの本質はcommitだ、というのはなんとなく知ってはいたものの、それがどういうことなのかきちんと理解していなかったので自分の知識定着も兼ねて記事にしておく。 2021-05-08 16:04:13
海外TECH DEV Community Do you use subdomains? https://dev.to/madza/do-you-use-subdomains-2go1 Do you use subdomains Subdomains are the part of a domain that comes before the main domain name and domain extension They are created to organize and navigate to different sections of the website Do you use subdomains for your personal domain like awesomeproject mydomain com If so could you elaborate on your reasons why do you prefer them over subdirectories like mydomain com awesomeproject or buying a dedicated domain like awesomeproject com 2021-05-08 07:41:52
海外TECH DEV Community Beautifully encapsulate table related logic using a custom data source + sorting using directives https://dev.to/angular/beautifully-encapsulate-table-related-logic-into-a-custom-data-source-sorting-using-directives-1pc7 Beautifully encapsulate table related logic using a custom data source sorting using directivesTables are a fundamental part of the web It is used in most of the applications out there to present data in a readable and digestible way Tables can come out as very simple components but they can be a real pain to work with if things are not organized properly The problemWhen the table we are dealing with has a lot of columns rows and multiple functionalities like sorting filtering etc things can get real complex real fast If we are not very careful in architecting tables for our applications there can be all sorts of issues that might come into the picture as we start developing This is the primary reason why we have a lot of table related libraries available One such great component for Angular is the Table component from Angular Material It s a very solid table component that can be used without any hassle and is well documented Features commonly seenThe most common features that can be seen in any table component are SortingFilteringPaginationetcImplementing these from scratch could take time and If you don t know what you are doing can lead to performance issues when dealing with huge data In this article I will be only focusing on managing the data for the table in a nice way and how to implement sorting in the table with the help of directives Creating the Data SourceThis approach is seen in the Angular Material table where we have the concept of Data Source Here is what the official doc says The DataSource is meant to serve as a place to encapsulate any sorting filtering pagination and data retrieval logic specific to the application The data source will be the one place where we will segregate all the logic related to the table In this way our component will not be polluted Also another benefit that we get is that the common functionalities can be shared We are going to try and build something similar to the Material DataSource The whole point of the post is to show you that you could do things this way too It s like a starting point for someone who would like to explore more on this stuff Creating an abstract classFirst we start by creating a simple abstract class that implements some of the basic stuff that we need for the table to work export abstract class DataSource lt T gt private subs new SubSink private dataSubject new Subject lt T gt The exposed observable for the table to user data this dataSubject asObservable constructor data T this updateData data destory this subs unsubscribe The data which drives the table It will accept either array or an observable param data data for the table updateData data T Observable lt T gt if isObservable data const sub data pipe tap res gt this dataSubject next res subscribe this subs add sub else this dataSubject next data Let me break down the code a bit The class DataSource lt T gt accepts a generic type that can be provided to have proper typing for the data subsink is a tiny little library that can help you manage your subscriptions with ease You can initialize it and add subscriptions to it subs add subscription and then dosubs unsubscribe to unsubscribe from all of the subscriptions Check it out here npm github Firstly Initialize a subject that will be used for pushing the data out of the data source The data observable is what our table will be relying on The constructor takes an initial value for the data source which is not mandatory The destory method does the cleanup of subscriptions and should be called in the table component s ngOnDestroy method The updateData method accepts either an array or an observable just for some flexibility This function can be used to update the data in the data source Say if you are getting data from an API call in the component you can call this method and pass the data to the data source Using it in the componentNow that we have our basic data source ready we can see how it can be used inside a component Once the component is created In my case User component the first thing we have to do is to create a dedicated data source for the User component I call it the UserDataSoruce We just have to create a class and extend our base DataSoruce export class UserDataSoruce extends DataSource lt User gt For now this is all we need Once we start implementing the sorting functionality more things will be added to the data source Setting up the component Component selector app user templateUrl user component html styleUrls user component css changeDetection ChangeDetectionStrategy OnPush export class UserComponent implements OnInit AfterViewInit OnDestroy userDataSoruce new UserDataSoruce Create the instance of datasoruce users Observable lt User gt this userDataSoruce data observable used by table constructor private userService UserService ngOnInit const users this userService getUsers pipe pluck data this userDataSoruce updateData users trackBy number user User return user email ngOnDestroy this userDataSoruce destory The interesting parts of the code above is creating the instance of our UserDataSoruce class And in the ngOnInit we get the user data from the API and is and the template file lt div gt lt table gt lt thead gt lt tr gt lt th gt First name lt th gt lt th gt Last name lt th gt lt th gt Birthday lt th gt lt tr gt lt thead gt lt tbody gt lt tr ngFor let user of users async trackBy trackBy gt lt td gt user firstname lt td gt lt td gt user lastname lt td gt lt td gt user birthday lt td gt lt tr gt lt tbody gt lt table gt lt div gt Our table should be up and running by now This would seem overly complicated for just showing some data in a table Yes it does But once we start to implement sorting and other features it will be clear why this would be a better approach Implementing SortingNow that we have the table and the data source setup it s time to implement sorting How would you normally implement sorting Will all the logic for sorting be added inside your component In this approach we are going to abstract away almost all of the logic related to sorting into our data source and by using directives So what we are trying to implement user should be able to sort the column in ascending or descending orderuser will be seeing the default sort data on clicking times Default gt Ascending gt Descending gt Defaultuser will be shown arrows to mark the current sort directionThe approach that we are going to take is very similar to what is seen in the Angular Material Sort component You will be able to understand some of the inner workings of it Creating the necessary directivesOur directives will be taking care of all the above points We don t have to maintain any kind of state inside our component making the component clean We will be needing two directives one is actually gonna be a component Main Sorter DirectiveSort Header Component Main Sorter DirectiveThis should be placed on the table tag and acts as our main parent Directive selector sorter lt selector export class Sorter active null direction null Output sortChange new EventEmitter lt SortChangeEvent gt sort column string let direction this direction If column is not the same as active reset the direction if this active column this direction null this active column Default gt Ascending if this direction null direction asc Ascending gt Descending else if this direction asc direction desc Descending gt Default else if this direction desc direction null Emit the current active column and the direction this sortChange emit column direction this direction direction There are two variables for managing the currently active column and the direction of sort Then we have an event that will be emitted when the user clicks on the sort header sort function takes the column id to sort as the input It just modifies the state according to the column being sorted and the prev state Sort Header componentSo we are using a component here as we need to show the arrow mark based on the sort direction Component selector sortHeader template lt div class sort col gt lt ng content gt lt ng content gt lt div ngClass arrow true hide sorter active ref sorter direction null asc sorter active ref amp amp sorter direction asc desc sorter active ref amp amp sorter direction desc gt 🡡 lt div gt lt div gt styles lt check the source code for styles export class SortHeader Input ref string lt unique key for the column HostListener click sort this sorter sort this ref lt call the sort function in the parent constructor private sorter Sorter lt Inject the parent directive The interesting part of the above code is constructor private sorter Sorter We are injecting our parent directive in the header component Angular s DI system will then provide us with access to the parent sorter where we have written our sort function Read more hierarchical injectors Now that we have our sort related directives ready this is how we update the template code lt div gt lt table sorter gt lt thead gt lt tr gt lt th ref firstname sortHeader gt First name lt th gt lt th ref lastname sortHeader gt Last name lt th gt lt th ref birthday sortHeader gt Birthday lt th gt lt tr gt lt thead gt lt tbody gt lt tr ngFor let user of users async trackBy trackBy gt lt td gt user firstname lt td gt lt td gt user lastname lt td gt lt td gt user birthday lt td gt lt tr gt lt tbody gt lt table gt lt div gt See that we have added the sorter selector to our lt table gt tag and sortHeader to our lt th gt along with the unique key for that column ref You can simple listen to the output and handle the change in your component like this lt table sorter sortChange handleSort event gt lt table gt But we will be doing something even better Updating DataSource to accommodate sorting featureWe are going to make few changes to our DataSoruce abstract class and add some for stuff so we can handle sorting export abstract class DataSource lt T gt private subs new SubSink to save the initial sort order private inititalDataSubject new Subject lt T gt initialData this inititalDataSubject asObservable private dataSubject new Subject lt T gt The exposed observable for the table to user data this dataSubject asObservable constructor data T this updateData data Register the sorter with the datasource set sorter sorter Sorter this listenToSortChanges sorter destory this subs unsubscribe updateData data T Observable lt T gt if isObservable data const sub data pipe tap res gt this dataSubject next res this inititalDataSubject next res subscribe this subs add sub else this dataSubject next data abstract sortLogic sorter SortChangeEvent data T T Update the data when the user sorts param sorter sorter instance private listenToSortChanges sorter Sorter const sub sorter sortChange pipe withLatestFrom this initialData lt get the data map sortEvent data gt this sortLogic sortEvent data catchError gt of subscribe data gt this dataSubject next data this subs add sub Here are the changes we made Add an abstract method sortLogic which gets the sort change event and the data It should return an array Add a setter to register our Sorter with data sourceWhat it does is that it listens to the sort change events and calls the sortLogic method which should be implemented by our UserDataSource Updating UserDataSourceNow we have to implement the sortLogic method in our UserDataSource export class UserDataSoruce extends DataSource lt User gt sortLogic column direction SortChangeEvent data User let sorted data if direction null return sorted switch column case birthday lt can provide custom sorting logic if needed sorted data sort a b gt const order direction asc if new Date a column gt new Date b column return order return order return sorted default sorted data sort a b gt const order direction asc if a column gt b column return order return order return sorted So the method sortLogic receives the SortChangeEvent and the table data as params We can use this info to sort the data and return it If a particular column needs custom sorting that can be handled here as well Updates to UserComponentOur component would look like this export class UserComponent implements OnInit AfterViewInit OnDestroy userDataSoruce new UserDataSoruce users Observable lt User gt this userDataSoruce data ViewChild Sorter sorter Sorter lt get the sorter instance constructor private userService UserService ngOnInit const users this userService getUsers pipe pluck data this userDataSoruce updateData users ngAfterViewInit this userDataSoruce sorter this sorter lt register it with data source trackBy number user User return user email ngOnDestroy this userDataSoruce destory We get hold of the Sorter instance using ViewChild ref and then register it with the data source in the ngAfterViewInit lifecycle hook We are done with the sorting implementation Now that table should be sorted when the user clicks on the header Final ThoughtsI wanted to write about things like these which are not seen very commonly we use libraries and never actually try to see how they are implemented So I just wanted to open up the minds of those who haven t actually understood how powerful Angular can be This won t be a perfect implementation we can bring in a lot of optimizations to the code We can extend this to include more functionalities like pagination filtering searching etc If you would like for me to write a continuation post please do comment down below Demo Connect with meTwitterGithubDo add your thoughts in the comments section Stay Safe ️ 2021-05-08 07:03:51
海外ニュース Japan Times latest articles Japan aiming for 1 million COVID-19 vaccine shots per day https://www.japantimes.co.jp/news/2021/05/08/national/million-vaccinations-japan-suga/ shots 2021-05-08 17:57:50
海外ニュース Japan Times latest articles Visit to Japan by IOC’s Bach expected to be canceled, report says https://www.japantimes.co.jp/news/2021/05/08/national/bach-olympics-visit-canceled/ Visit to Japan by IOC s Bach expected to be canceled report saysPublic broadcaster NHK reported that the visit is now expected to be canceled given that the coronavirus state of emergency has been extended in Tokyo 2021-05-08 17:43:28
海外ニュース Japan Times latest articles Japan logs record-breaking coronavirus numbers https://www.japantimes.co.jp/news/2021/05/08/national/japan-coronavirus-deaths-emergency/ Japan logs record breaking coronavirus numbersThe country recorded deaths while COVID patients with severe symptoms hit an all time high of as the daily number of new infections topped 2021-05-08 17:38:49
ニュース BBC News - Home Welsh election results 2021: Labour set to stay in power https://www.bbc.co.uk/news/uk-wales-politics-57009547 senedd 2021-05-08 07:52:36
ニュース BBC News - Home High-speed rail services cancelled after cracks found in trains https://www.bbc.co.uk/news/uk-57036247 hitachi 2021-05-08 07:41:51
LifeHuck ライフハッカー[日本版] 自宅で上質なひとときを。細部まで美しいお香立てを使ってみた https://www.lifehacker.jp/2021/05/machi-ya-rin-review.html 仕上がり 2021-05-08 16:30:00
北海道 北海道新聞 9日の予告先発 日ハムは池田 https://www.hokkaido-np.co.jp/article/541517/ 東京ドーム 2021-05-08 16:14:00
IT 週刊アスキー 「雪見だいふく 八天堂監修カスタードくりーむ味」とろ~りとしたカスタード入り https://weekly.ascii.jp/elem/000/004/053/4053927/ 雪見だいふく 2021-05-08 16:30:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)